IApplicationHost.cs 4.0 KB

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