2
0

IApplicationHost.cs 4.2 KB

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