IApplicationHost.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Common.Plugins;
  6. using MediaBrowser.Model.Events;
  7. using MediaBrowser.Model.Updates;
  8. using Microsoft.Extensions.DependencyInjection;
  9. namespace MediaBrowser.Common
  10. {
  11. /// <summary>
  12. /// An interface to be implemented by the applications hosting a kernel
  13. /// </summary>
  14. public interface IApplicationHost
  15. {
  16. /// <summary>
  17. /// Gets the name.
  18. /// </summary>
  19. /// <value>The name.</value>
  20. string Name { get; }
  21. /// <summary>
  22. /// Gets the device identifier.
  23. /// </summary>
  24. /// <value>The device identifier.</value>
  25. string SystemId { get; }
  26. /// <summary>
  27. /// Occurs when [application updated].
  28. /// </summary>
  29. event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated;
  30. /// <summary>
  31. /// Gets or sets a value indicating whether this instance has pending kernel reload.
  32. /// </summary>
  33. /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
  34. bool HasPendingRestart { get; }
  35. bool IsShuttingDown { get; }
  36. /// <summary>
  37. /// Gets a value indicating whether this instance can self restart.
  38. /// </summary>
  39. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  40. bool CanSelfRestart { get; }
  41. /// <summary>
  42. /// Occurs when [has pending restart changed].
  43. /// </summary>
  44. event EventHandler HasPendingRestartChanged;
  45. /// <summary>
  46. /// Notifies the pending restart.
  47. /// </summary>
  48. void NotifyPendingRestart();
  49. /// <summary>
  50. /// Restarts this instance.
  51. /// </summary>
  52. void Restart();
  53. /// <summary>
  54. /// Gets the application version.
  55. /// </summary>
  56. /// <value>The application version.</value>
  57. string ApplicationVersion { 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 exports.
  65. /// </summary>
  66. /// <typeparam name="T"></typeparam>
  67. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  68. /// <returns>IEnumerable{``0}.</returns>
  69. IEnumerable<T> GetExports<T>(bool manageLifetime = true);
  70. /// <summary>
  71. /// Resolves this instance.
  72. /// </summary>
  73. /// <typeparam name="T"></typeparam>
  74. /// <returns>``0.</returns>
  75. T Resolve<T>();
  76. /// <summary>
  77. /// Shuts down.
  78. /// </summary>
  79. Task Shutdown();
  80. /// <summary>
  81. /// Gets the plugins.
  82. /// </summary>
  83. /// <value>The plugins.</value>
  84. IPlugin[] Plugins { get; }
  85. /// <summary>
  86. /// Removes the plugin.
  87. /// </summary>
  88. /// <param name="plugin">The plugin.</param>
  89. void RemovePlugin(IPlugin plugin);
  90. /// <summary>
  91. /// Inits this instance.
  92. /// </summary>
  93. Task Init(IServiceCollection serviceCollection);
  94. /// <summary>
  95. /// Creates the instance.
  96. /// </summary>
  97. /// <param name="type">The type.</param>
  98. /// <returns>System.Object.</returns>
  99. object CreateInstance(Type type);
  100. PackageVersionClass SystemUpdateLevel { get; }
  101. }
  102. }