IPluginManager.cs 2.9 KB

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