IApplicationHost.cs 4.1 KB

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