IPluginManager.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Model.Plugins;
  6. using MediaBrowser.Model.Updates;
  7. using Microsoft.Extensions.DependencyInjection;
  8. namespace MediaBrowser.Common.Plugins
  9. {
  10. /// <summary>
  11. /// Defines the <see cref="IPluginManager" />.
  12. /// </summary>
  13. public interface IPluginManager
  14. {
  15. /// <summary>
  16. /// Gets the Plugins.
  17. /// </summary>
  18. IReadOnlyList<LocalPlugin> Plugins { get; }
  19. /// <summary>
  20. /// Creates the plugins.
  21. /// </summary>
  22. void CreatePlugins();
  23. /// <summary>
  24. /// Returns all the assemblies.
  25. /// </summary>
  26. /// <returns>An IEnumerable{Assembly}.</returns>
  27. IEnumerable<Assembly> LoadAssemblies();
  28. /// <summary>
  29. /// Unloads all of the assemblies.
  30. /// </summary>
  31. void UnloadAssemblies();
  32. /// <summary>
  33. /// Registers the plugin's services with the DI.
  34. /// Note: DI is not yet instantiated yet.
  35. /// </summary>
  36. /// <param name="serviceCollection">A <see cref="ServiceCollection"/> instance.</param>
  37. void RegisterServices(IServiceCollection serviceCollection);
  38. /// <summary>
  39. /// Saves the manifest back to disk.
  40. /// </summary>
  41. /// <param name="manifest">The <see cref="PluginManifest"/> to save.</param>
  42. /// <param name="path">The path where to save the manifest.</param>
  43. /// <returns>True if successful.</returns>
  44. bool SaveManifest(PluginManifest manifest, string path);
  45. /// <summary>
  46. /// Generates a manifest from repository data.
  47. /// </summary>
  48. /// <param name="packageInfo">The <see cref="PackageInfo"/> used to generate a manifest.</param>
  49. /// <param name="version">Version to be installed.</param>
  50. /// <param name="path">The path where to save the manifest.</param>
  51. /// <param name="status">Initial status of the plugin.</param>
  52. /// <returns>True if successful.</returns>
  53. Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path, PluginStatus status);
  54. /// <summary>
  55. /// Imports plugin details from a folder.
  56. /// </summary>
  57. /// <param name="folder">Folder of the plugin.</param>
  58. void ImportPluginFrom(string folder);
  59. /// <summary>
  60. /// Disable the plugin.
  61. /// </summary>
  62. /// <param name="assembly">The <see cref="Assembly"/> of the plug to disable.</param>
  63. void FailPlugin(Assembly assembly);
  64. /// <summary>
  65. /// Disable the plugin.
  66. /// </summary>
  67. /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
  68. void DisablePlugin(LocalPlugin plugin);
  69. /// <summary>
  70. /// Enables the plugin, disabling all other versions.
  71. /// </summary>
  72. /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
  73. void EnablePlugin(LocalPlugin plugin);
  74. /// <summary>
  75. /// Attempts to find the plugin with and id of <paramref name="id"/>.
  76. /// </summary>
  77. /// <param name="id">Id of plugin.</param>
  78. /// <param name="version">The version of the plugin to locate.</param>
  79. /// <returns>A <see cref="LocalPlugin"/> if located, or null if not.</returns>
  80. LocalPlugin? GetPlugin(Guid id, Version? version = null);
  81. /// <summary>
  82. /// Removes the plugin.
  83. /// </summary>
  84. /// <param name="plugin">The plugin.</param>
  85. /// <returns>Outcome of the operation.</returns>
  86. bool RemovePlugin(LocalPlugin plugin);
  87. }
  88. }