IApplicationHost.cs 4.1 KB

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