IApplicationHost.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using MediaBrowser.Common.Plugins;
  5. using MediaBrowser.Model.Updates;
  6. using Microsoft.Extensions.Configuration;
  7. using Microsoft.Extensions.DependencyInjection;
  8. namespace MediaBrowser.Common
  9. {
  10. /// <summary>
  11. /// An interface to be implemented by the applications hosting a kernel.
  12. /// </summary>
  13. public interface IApplicationHost
  14. {
  15. /// <summary>
  16. /// Occurs when [has pending restart changed].
  17. /// </summary>
  18. event EventHandler HasPendingRestartChanged;
  19. /// <summary>
  20. /// Gets the name.
  21. /// </summary>
  22. /// <value>The name.</value>
  23. string Name { get; }
  24. /// <summary>
  25. /// Gets the device identifier.
  26. /// </summary>
  27. /// <value>The device identifier.</value>
  28. string SystemId { get; }
  29. /// <summary>
  30. /// Gets a value indicating whether this instance has pending kernel reload.
  31. /// </summary>
  32. /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
  33. bool HasPendingRestart { get; }
  34. /// <summary>
  35. /// Gets a value indicating whether this instance is currently shutting down.
  36. /// </summary>
  37. /// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value>
  38. bool IsShuttingDown { get; }
  39. /// <summary>
  40. /// Gets a value indicating whether this instance can self restart.
  41. /// </summary>
  42. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  43. bool CanSelfRestart { get; }
  44. /// <summary>
  45. /// Gets the application version.
  46. /// </summary>
  47. /// <value>The application version.</value>
  48. Version ApplicationVersion { get; }
  49. /// <summary>
  50. /// Gets the application version.
  51. /// </summary>
  52. /// <value>The application version.</value>
  53. string ApplicationVersionString { get; }
  54. /// <summary>
  55. /// Gets the application user agent.
  56. /// </summary>
  57. /// <value>The application user agent.</value>
  58. string ApplicationUserAgent { get; }
  59. /// <summary>
  60. /// Gets the email address for use within a comment section of a user agent field.
  61. /// Presently used to provide contact information to MusicBrainz service.
  62. /// </summary>
  63. string ApplicationUserAgentAddress { get; }
  64. /// <summary>
  65. /// Gets the plugins.
  66. /// </summary>
  67. /// <value>The plugins.</value>
  68. IReadOnlyList<IPlugin> Plugins { get; }
  69. /// <summary>
  70. /// Notifies the pending restart.
  71. /// </summary>
  72. void NotifyPendingRestart();
  73. /// <summary>
  74. /// Restarts this instance.
  75. /// </summary>
  76. void Restart();
  77. /// <summary>
  78. /// Gets the exports.
  79. /// </summary>
  80. /// <typeparam name="T">The type.</typeparam>
  81. /// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
  82. /// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
  83. IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true);
  84. /// <summary>
  85. /// Resolves this instance.
  86. /// </summary>
  87. /// <typeparam name="T">The <c>Type</c>.</typeparam>
  88. /// <returns>``0.</returns>
  89. T Resolve<T>();
  90. /// <summary>
  91. /// Shuts down.
  92. /// </summary>
  93. /// <returns>A task.</returns>
  94. Task Shutdown();
  95. /// <summary>
  96. /// Removes the plugin.
  97. /// </summary>
  98. /// <param name="plugin">The plugin.</param>
  99. void RemovePlugin(IPlugin plugin);
  100. /// <summary>
  101. /// Initializes this instance.
  102. /// </summary>
  103. /// <param name="serviceCollection">The service collection.</param>
  104. /// <param name="startupConfig">The configuration to use for initialization.</param>
  105. /// <returns>A task.</returns>
  106. Task InitAsync(IServiceCollection serviceCollection, IConfiguration startupConfig);
  107. /// <summary>
  108. /// Creates the instance.
  109. /// </summary>
  110. /// <param name="type">The type.</param>
  111. /// <returns>System.Object.</returns>
  112. object CreateInstance(Type type);
  113. }
  114. }