IApplicationHost.cs 3.5 KB

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