IApplicationHost.cs 3.7 KB

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