IApplicationHost.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using MediaBrowser.Common.Plugins;
  2. using MediaBrowser.Model.Updates;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace MediaBrowser.Common
  8. {
  9. /// <summary>
  10. /// An interface to be implemented by the applications hosting a kernel
  11. /// </summary>
  12. public interface IApplicationHost
  13. {
  14. /// <summary>
  15. /// Performs the pending restart.
  16. /// </summary>
  17. void PerformPendingRestart();
  18. /// <summary>
  19. /// Gets or sets a value indicating whether this instance has pending kernel reload.
  20. /// </summary>
  21. /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
  22. bool HasPendingRestart { get; }
  23. /// <summary>
  24. /// Occurs when [has pending restart changed].
  25. /// </summary>
  26. event EventHandler HasPendingRestartChanged;
  27. /// <summary>
  28. /// Notifies the pending restart.
  29. /// </summary>
  30. void NotifyPendingRestart();
  31. /// <summary>
  32. /// Restarts this instance.
  33. /// </summary>
  34. void Restart();
  35. /// <summary>
  36. /// Gets the application version.
  37. /// </summary>
  38. /// <value>The application version.</value>
  39. Version ApplicationVersion { get; }
  40. /// <summary>
  41. /// Gets or sets a value indicating whether this instance can self update.
  42. /// </summary>
  43. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  44. bool CanSelfUpdate { get; }
  45. /// <summary>
  46. /// Gets a value indicating whether this instance is first run.
  47. /// </summary>
  48. /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
  49. bool IsFirstRun { get; }
  50. /// <summary>
  51. /// Gets the failed assemblies.
  52. /// </summary>
  53. /// <value>The failed assemblies.</value>
  54. List<string> FailedAssemblies { get; }
  55. /// <summary>
  56. /// Gets all concrete types.
  57. /// </summary>
  58. /// <value>All concrete types.</value>
  59. Type[] AllConcreteTypes { get; }
  60. /// <summary>
  61. /// Gets the exports.
  62. /// </summary>
  63. /// <typeparam name="T"></typeparam>
  64. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  65. /// <returns>IEnumerable{``0}.</returns>
  66. IEnumerable<T> GetExports<T>(bool manageLiftime = true);
  67. /// <summary>
  68. /// Checks for update.
  69. /// </summary>
  70. /// <returns>Task{CheckForUpdateResult}.</returns>
  71. Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
  72. /// <summary>
  73. /// Updates the application.
  74. /// </summary>
  75. /// <returns>Task.</returns>
  76. Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress);
  77. /// <summary>
  78. /// Creates an instance of type and resolves all constructor dependancies
  79. /// </summary>
  80. /// <param name="type">The type.</param>
  81. /// <returns>System.Object.</returns>
  82. object CreateInstance(Type type);
  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. void 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. }
  115. }