IApplicationHost.cs 4.4 KB

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