IPluginManager.cs 2.9 KB

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