IApplicationHost.cs 4.4 KB

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