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