IPluginManager.cs 3.6 KB

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