IApplicationHost.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 or sets a value indicating whether this instance can self update.
  65. /// </summary>
  66. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  67. bool CanSelfUpdate { get; }
  68. /// <summary>
  69. /// Gets the exports.
  70. /// </summary>
  71. /// <typeparam name="T"></typeparam>
  72. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  73. /// <returns>IEnumerable{``0}.</returns>
  74. IEnumerable<T> GetExports<T>(bool manageLifetime = true);
  75. /// <summary>
  76. /// Updates the application.
  77. /// </summary>
  78. /// <returns>Task.</returns>
  79. Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress);
  80. /// <summary>
  81. /// Resolves this instance.
  82. /// </summary>
  83. /// <typeparam name="T"></typeparam>
  84. /// <returns>``0.</returns>
  85. T Resolve<T>();
  86. /// <summary>
  87. /// Shuts down.
  88. /// </summary>
  89. Task Shutdown();
  90. /// <summary>
  91. /// Gets the plugins.
  92. /// </summary>
  93. /// <value>The plugins.</value>
  94. IPlugin[] Plugins { get; }
  95. /// <summary>
  96. /// Removes the plugin.
  97. /// </summary>
  98. /// <param name="plugin">The plugin.</param>
  99. void RemovePlugin(IPlugin plugin);
  100. /// <summary>
  101. /// Inits this instance.
  102. /// </summary>
  103. Task Init(IServiceCollection serviceCollection);
  104. /// <summary>
  105. /// Creates the instance.
  106. /// </summary>
  107. /// <param name="type">The type.</param>
  108. /// <returns>System.Object.</returns>
  109. object CreateInstance(Type type);
  110. PackageVersionClass SystemUpdateLevel { get; }
  111. }
  112. }