2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Collections.Generic;
|
2020-08-11 08:04:11 -07:00
|
|
|
using System.Reflection;
|
2021-11-02 08:02:52 -07:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Common
|
|
|
|
{
|
2020-12-06 16:48:54 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Delegate used with GetExports{T}.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="type">Type to create.</param>
|
|
|
|
/// <returns>New instance of type <param>type</param>.</returns>
|
2021-05-28 05:33:54 -07:00
|
|
|
public delegate object? CreationDelegateFactory(Type type);
|
2020-12-06 16:48:54 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
2019-12-10 16:13:57 -07:00
|
|
|
/// An interface to be implemented by the applications hosting a kernel.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
public interface IApplicationHost
|
|
|
|
{
|
2019-12-10 16:13:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [has pending restart changed].
|
|
|
|
/// </summary>
|
2021-05-28 05:33:54 -07:00
|
|
|
event EventHandler? HasPendingRestartChanged;
|
2019-12-10 16:13:57 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the name.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The name.</value>
|
|
|
|
string Name { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the device identifier.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The device identifier.</value>
|
|
|
|
string SystemId { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
2019-12-10 16:13:57 -07:00
|
|
|
/// Gets a value indicating whether this instance has pending kernel reload.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
|
|
|
|
bool HasPendingRestart { get; }
|
|
|
|
|
2019-10-09 08:10:16 -07:00
|
|
|
/// <summary>
|
2023-10-02 12:55:26 -07:00
|
|
|
/// Gets a value indicating whether this instance is currently shutting down.
|
2019-10-09 08:10:16 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value>
|
2023-10-02 12:55:26 -07:00
|
|
|
bool IsShuttingDown { get; }
|
2023-09-22 18:10:49 -07:00
|
|
|
|
|
|
|
/// <summary>
|
2023-10-02 12:55:26 -07:00
|
|
|
/// Gets a value indicating whether the application should restart.
|
2023-09-22 18:10:49 -07:00
|
|
|
/// </summary>
|
2023-10-02 12:55:26 -07:00
|
|
|
bool ShouldRestart { get; }
|
2018-12-27 16:27:57 -07:00
|
|
|
|
2019-01-19 17:12:44 -07:00
|
|
|
/// <summary>
|
2019-01-19 19:35:33 -07:00
|
|
|
/// Gets the application version.
|
2019-01-19 17:12:44 -07:00
|
|
|
/// </summary>
|
2019-01-19 19:35:33 -07:00
|
|
|
/// <value>The application version.</value>
|
2019-10-08 11:51:11 -07:00
|
|
|
Version ApplicationVersion { get; }
|
|
|
|
|
2020-12-06 16:48:54 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the service provider.
|
|
|
|
/// </summary>
|
2021-05-28 05:33:54 -07:00
|
|
|
IServiceProvider? ServiceProvider { get; set; }
|
2020-12-06 16:48:54 -07:00
|
|
|
|
2019-10-08 11:51:11 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the application version.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The application version.</value>
|
|
|
|
string ApplicationVersionString { get; }
|
2019-01-19 17:12:44 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the application user agent.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The application user agent.</value>
|
|
|
|
string ApplicationUserAgent { get; }
|
|
|
|
|
2019-03-14 14:32:27 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the email address for use within a comment section of a user agent field.
|
|
|
|
/// Presently used to provide contact information to MusicBrainz service.
|
|
|
|
/// </summary>
|
|
|
|
string ApplicationUserAgentAddress { get; }
|
|
|
|
|
2020-08-11 08:04:11 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets all plugin assemblies which implement a custom rest api.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>An <see cref="IEnumerable{Assembly}"/> containing the plugin assemblies.</returns>
|
|
|
|
IEnumerable<Assembly> GetApiPluginAssemblies();
|
|
|
|
|
2019-12-10 16:13:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Notifies the pending restart.
|
|
|
|
/// </summary>
|
|
|
|
void NotifyPendingRestart();
|
|
|
|
|
2023-10-02 12:55:26 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Restarts this instance.
|
|
|
|
/// </summary>
|
|
|
|
void Restart();
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the exports.
|
|
|
|
/// </summary>
|
2019-08-11 07:52:37 -07:00
|
|
|
/// <typeparam name="T">The type.</typeparam>
|
|
|
|
/// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
|
|
|
|
/// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
|
|
|
|
IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true);
|
2018-12-27 16:27:57 -07:00
|
|
|
|
2020-12-06 16:48:54 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the exports.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">The type.</typeparam>
|
|
|
|
/// <param name="defaultFunc">Delegate function that gets called to create the object.</param>
|
|
|
|
/// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
|
|
|
|
/// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
|
2021-03-08 21:57:38 -07:00
|
|
|
IReadOnlyCollection<T> GetExports<T>(CreationDelegateFactory defaultFunc, bool manageLifetime = true);
|
2020-12-06 16:48:54 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the export types.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">The type.</typeparam>
|
|
|
|
/// <returns>IEnumerable{Type}.</returns>
|
|
|
|
IEnumerable<Type> GetExportTypes<T>();
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Resolves this instance.
|
|
|
|
/// </summary>
|
2019-12-10 16:13:57 -07:00
|
|
|
/// <typeparam name="T">The <c>Type</c>.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <returns>``0.</returns>
|
|
|
|
T Resolve<T>();
|
|
|
|
|
2023-10-02 12:55:26 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Shuts down.
|
|
|
|
/// </summary>
|
|
|
|
void Shutdown();
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
2020-02-28 15:28:15 -07:00
|
|
|
/// Initializes this instance.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
2021-11-02 08:02:52 -07:00
|
|
|
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
|
|
|
|
void Init(IServiceCollection serviceCollection);
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
}
|