IApplicationHost.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using MediaBrowser.Model.Updates;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Common.Kernel
  7. {
  8. /// <summary>
  9. /// An interface to be implemented by the applications hosting a kernel
  10. /// </summary>
  11. public interface IApplicationHost
  12. {
  13. /// <summary>
  14. /// Restarts this instance.
  15. /// </summary>
  16. void Restart();
  17. /// <summary>
  18. /// Reloads the logger.
  19. /// </summary>
  20. void ReloadLogger();
  21. /// <summary>
  22. /// Gets the log file path.
  23. /// </summary>
  24. /// <value>The log file path.</value>
  25. string LogFilePath { get; }
  26. /// <summary>
  27. /// Gets or sets a value indicating whether this instance can self update.
  28. /// </summary>
  29. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  30. bool CanSelfUpdate { get; }
  31. /// <summary>
  32. /// Gets the failed assemblies.
  33. /// </summary>
  34. /// <value>The failed assemblies.</value>
  35. IEnumerable<string> FailedAssemblies { get; }
  36. /// <summary>
  37. /// Gets all concrete types.
  38. /// </summary>
  39. /// <value>All concrete types.</value>
  40. Type[] AllConcreteTypes { get; }
  41. /// <summary>
  42. /// Gets the exports.
  43. /// </summary>
  44. /// <typeparam name="T"></typeparam>
  45. /// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
  46. /// <returns>IEnumerable{``0}.</returns>
  47. IEnumerable<T> GetExports<T>(bool manageLiftime = true);
  48. /// <summary>
  49. /// Checks for update.
  50. /// </summary>
  51. /// <returns>Task{CheckForUpdateResult}.</returns>
  52. Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress);
  53. /// <summary>
  54. /// Updates the application.
  55. /// </summary>
  56. /// <returns>Task.</returns>
  57. Task UpdateApplication(CancellationToken cancellationToken, IProgress<double> progress);
  58. /// <summary>
  59. /// Creates an instance of type and resolves all constructor dependancies
  60. /// </summary>
  61. /// <param name="type">The type.</param>
  62. /// <returns>System.Object.</returns>
  63. object CreateInstance(Type type);
  64. /// <summary>
  65. /// Registers a service that other classes can use as a dependancy.
  66. /// </summary>
  67. /// <typeparam name="T"></typeparam>
  68. /// <param name="obj">The obj.</param>
  69. void RegisterSingleInstance<T>(T obj) where T : class;
  70. /// <summary>
  71. /// Registers the single instance.
  72. /// </summary>
  73. /// <typeparam name="T"></typeparam>
  74. /// <param name="func">The func.</param>
  75. void RegisterSingleInstance<T>(Func<T> func) where T : class;
  76. /// <summary>
  77. /// Registers the specified func.
  78. /// </summary>
  79. /// <typeparam name="T"></typeparam>
  80. /// <param name="func">The func.</param>
  81. void Register<T>(Func<T> func) where T : class;
  82. /// <summary>
  83. /// Registers the specified service type.
  84. /// </summary>
  85. /// <param name="serviceType">Type of the service.</param>
  86. /// <param name="implementation">Type of the implementation.</param>
  87. void Register(Type serviceType, Type implementation);
  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. }
  101. }