IApplicationHost.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using MediaBrowser.Common.Plugins;
  2. using MediaBrowser.Model.Events;
  3. using MediaBrowser.Model.Updates;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace MediaBrowser.Common
  9. {
  10. /// <summary>
  11. /// An interface to be implemented by the applications hosting a kernel
  12. /// </summary>
  13. public interface IApplicationHost
  14. {
  15. /// <summary>
  16. /// Gets the display name of the operating system.
  17. /// </summary>
  18. /// <value>The display name of the operating system.</value>
  19. string OperatingSystemDisplayName { get; }
  20. /// <summary>
  21. /// Gets the name.
  22. /// </summary>
  23. /// <value>The name.</value>
  24. string Name { get; }
  25. /// <summary>
  26. /// Gets the device identifier.
  27. /// </summary>
  28. /// <value>The device identifier.</value>
  29. string SystemId { get; }
  30. /// <summary>
  31. /// Occurs when [application updated].
  32. /// </summary>
  33. event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated;
  34. /// <summary>
  35. /// Gets a value indicating whether this instance is running as service.
  36. /// </summary>
  37. /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
  38. bool IsRunningAsService { get; }
  39. /// <summary>
  40. /// Gets or sets a value indicating whether this instance has pending kernel reload.
  41. /// </summary>
  42. /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
  43. bool HasPendingRestart { get; }
  44. /// <summary>
  45. /// Gets a value indicating whether this instance can self restart.
  46. /// </summary>
  47. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  48. bool CanSelfRestart { get; }
  49. /// <summary>
  50. /// Occurs when [has pending restart changed].
  51. /// </summary>
  52. event EventHandler HasPendingRestartChanged;
  53. /// <summary>
  54. /// Notifies the pending restart.
  55. /// </summary>
  56. void NotifyPendingRestart();
  57. /// <summary>
  58. /// Restarts this instance.
  59. /// </summary>
  60. Task Restart();
  61. /// <summary>
  62. /// Gets the application version.
  63. /// </summary>
  64. /// <value>The application version.</value>
  65. Version ApplicationVersion { get; }
  66. /// <summary>
  67. /// Gets or sets a value indicating whether this instance can self update.
  68. /// </summary>
  69. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  70. bool CanSelfUpdate { get; }
  71. /// <summary>
  72. /// Gets a value indicating whether this instance is first run.
  73. /// </summary>
  74. /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
  75. bool IsFirstRun { get; }
  76. /// <summary>
  77. /// Gets the failed assemblies.
  78. /// </summary>
  79. /// <value>The failed assemblies.</value>
  80. List<string> FailedAssemblies { get; }
  81. /// <summary>
  82. /// Gets all concrete types.
  83. /// </summary>
  84. /// <value>All concrete types.</value>
  85. Type[] AllConcreteTypes { get; }
  86. /// <summary>
  87. /// Gets the exports.
  88. /// </summary>
  89. /// <typeparam name="T"></typeparam>
  90. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  91. /// <returns>IEnumerable{``0}.</returns>
  92. IEnumerable<T> GetExports<T>(bool manageLiftime = true);
  93. /// <summary>
  94. /// Checks for update.
  95. /// </summary>
  96. /// <returns>Task{CheckForUpdateResult}.</returns>
  97. Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
  98. /// <summary>
  99. /// Updates the application.
  100. /// </summary>
  101. /// <returns>Task.</returns>
  102. Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress);
  103. /// <summary>
  104. /// Resolves this instance.
  105. /// </summary>
  106. /// <typeparam name="T"></typeparam>
  107. /// <returns>``0.</returns>
  108. T Resolve<T>();
  109. /// <summary>
  110. /// Resolves this instance.
  111. /// </summary>
  112. /// <typeparam name="T"></typeparam>
  113. /// <returns>``0.</returns>
  114. T TryResolve<T>();
  115. /// <summary>
  116. /// Shuts down.
  117. /// </summary>
  118. Task Shutdown();
  119. /// <summary>
  120. /// Gets the plugins.
  121. /// </summary>
  122. /// <value>The plugins.</value>
  123. IEnumerable<IPlugin> Plugins { get; }
  124. /// <summary>
  125. /// Removes the plugin.
  126. /// </summary>
  127. /// <param name="plugin">The plugin.</param>
  128. void RemovePlugin(IPlugin plugin);
  129. /// <summary>
  130. /// Inits this instance.
  131. /// </summary>
  132. /// <param name="progress">The progress.</param>
  133. /// <returns>Task.</returns>
  134. Task Init(IProgress<double> progress);
  135. /// <summary>
  136. /// Creates the instance.
  137. /// </summary>
  138. /// <param name="type">The type.</param>
  139. /// <returns>System.Object.</returns>
  140. object CreateInstance(Type type);
  141. }
  142. }