IApplicationHost.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 or sets a value indicating whether this instance has pending kernel reload.
  36. /// </summary>
  37. /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
  38. bool HasPendingRestart { get; }
  39. bool IsShuttingDown { get; }
  40. /// <summary>
  41. /// Gets a value indicating whether this instance can self restart.
  42. /// </summary>
  43. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  44. bool CanSelfRestart { get; }
  45. /// <summary>
  46. /// Occurs when [has pending restart changed].
  47. /// </summary>
  48. event EventHandler HasPendingRestartChanged;
  49. /// <summary>
  50. /// Notifies the pending restart.
  51. /// </summary>
  52. void NotifyPendingRestart();
  53. /// <summary>
  54. /// Restarts this instance.
  55. /// </summary>
  56. void Restart();
  57. /// <summary>
  58. /// Gets the application version.
  59. /// </summary>
  60. /// <value>The application version.</value>
  61. Version ApplicationVersion { get; }
  62. /// <summary>
  63. /// Gets or sets a value indicating whether this instance can self update.
  64. /// </summary>
  65. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  66. bool CanSelfUpdate { get; }
  67. /// <summary>
  68. /// Gets a value indicating whether this instance is first run.
  69. /// </summary>
  70. /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
  71. bool IsFirstRun { get; }
  72. /// <summary>
  73. /// Gets the failed assemblies.
  74. /// </summary>
  75. /// <value>The failed assemblies.</value>
  76. List<string> FailedAssemblies { get; }
  77. /// <summary>
  78. /// Gets all concrete types.
  79. /// </summary>
  80. /// <value>All concrete types.</value>
  81. Type[] AllConcreteTypes { get; }
  82. /// <summary>
  83. /// Gets the exports.
  84. /// </summary>
  85. /// <typeparam name="T"></typeparam>
  86. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  87. /// <returns>IEnumerable{``0}.</returns>
  88. IEnumerable<T> GetExports<T>(bool manageLiftime = true);
  89. /// <summary>
  90. /// Checks for update.
  91. /// </summary>
  92. /// <returns>Task{CheckForUpdateResult}.</returns>
  93. Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
  94. /// <summary>
  95. /// Updates the application.
  96. /// </summary>
  97. /// <returns>Task.</returns>
  98. Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress);
  99. /// <summary>
  100. /// Resolves this instance.
  101. /// </summary>
  102. /// <typeparam name="T"></typeparam>
  103. /// <returns>``0.</returns>
  104. T Resolve<T>();
  105. /// <summary>
  106. /// Resolves this instance.
  107. /// </summary>
  108. /// <typeparam name="T"></typeparam>
  109. /// <returns>``0.</returns>
  110. T TryResolve<T>();
  111. /// <summary>
  112. /// Shuts down.
  113. /// </summary>
  114. Task Shutdown();
  115. /// <summary>
  116. /// Gets the plugins.
  117. /// </summary>
  118. /// <value>The plugins.</value>
  119. IPlugin[] Plugins { get; }
  120. /// <summary>
  121. /// Removes the plugin.
  122. /// </summary>
  123. /// <param name="plugin">The plugin.</param>
  124. void RemovePlugin(IPlugin plugin);
  125. /// <summary>
  126. /// Inits this instance.
  127. /// </summary>
  128. /// <param name="progress">The progress.</param>
  129. /// <returns>Task.</returns>
  130. Task Init(IProgress<double> progress);
  131. /// <summary>
  132. /// Creates the instance.
  133. /// </summary>
  134. /// <param name="type">The type.</param>
  135. /// <returns>System.Object.</returns>
  136. object CreateInstance(Type type);
  137. PackageVersionClass SystemUpdateLevel { get; }
  138. }
  139. }