IApplicationHost.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 version class of the system.
  46. /// </summary>
  47. /// <value><see cref="PackageVersionClass.Release" /> or <see cref="PackageVersionClass.Beta" />.</value>
  48. PackageVersionClass SystemUpdateLevel { get; }
  49. /// <summary>
  50. /// Gets the application version.
  51. /// </summary>
  52. /// <value>The application version.</value>
  53. Version ApplicationVersion { get; }
  54. /// <summary>
  55. /// Gets the application version.
  56. /// </summary>
  57. /// <value>The application version.</value>
  58. string ApplicationVersionString { get; }
  59. /// <summary>
  60. /// Gets the application user agent.
  61. /// </summary>
  62. /// <value>The application user agent.</value>
  63. string ApplicationUserAgent { get; }
  64. /// <summary>
  65. /// Gets the email address for use within a comment section of a user agent field.
  66. /// Presently used to provide contact information to MusicBrainz service.
  67. /// </summary>
  68. string ApplicationUserAgentAddress { get; }
  69. /// <summary>
  70. /// Gets the plugins.
  71. /// </summary>
  72. /// <value>The plugins.</value>
  73. IReadOnlyList<IPlugin> Plugins { get; }
  74. /// <summary>
  75. /// Notifies the pending restart.
  76. /// </summary>
  77. void NotifyPendingRestart();
  78. /// <summary>
  79. /// Restarts this instance.
  80. /// </summary>
  81. void Restart();
  82. /// <summary>
  83. /// Gets the exports.
  84. /// </summary>
  85. /// <typeparam name="T">The type.</typeparam>
  86. /// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
  87. /// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
  88. IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true);
  89. /// <summary>
  90. /// Resolves this instance.
  91. /// </summary>
  92. /// <typeparam name="T">The <c>Type</c>.</typeparam>
  93. /// <returns>``0.</returns>
  94. T Resolve<T>();
  95. /// <summary>
  96. /// Shuts down.
  97. /// </summary>
  98. /// <returns>A task.</returns>
  99. Task Shutdown();
  100. /// <summary>
  101. /// Removes the plugin.
  102. /// </summary>
  103. /// <param name="plugin">The plugin.</param>
  104. void RemovePlugin(IPlugin plugin);
  105. /// <summary>
  106. /// Initializes this instance.
  107. /// </summary>
  108. /// <param name="serviceCollection">The service collection.</param>
  109. void Init(IServiceCollection serviceCollection);
  110. /// <summary>
  111. /// Creates the instance.
  112. /// </summary>
  113. /// <param name="type">The type.</param>
  114. /// <returns>System.Object.</returns>
  115. object CreateInstance(Type type);
  116. }
  117. }