2
0

IPluginManager.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /// Registers the plugin's services with the DI.
  30. /// Note: DI is not yet instantiated yet.
  31. /// </summary>
  32. /// <param name="serviceCollection">A <see cref="ServiceCollection"/> instance.</param>
  33. void RegisterServices(IServiceCollection serviceCollection);
  34. /// <summary>
  35. /// Saves the manifest back to disk.
  36. /// </summary>
  37. /// <param name="manifest">The <see cref="PluginManifest"/> to save.</param>
  38. /// <param name="path">The path where to save the manifest.</param>
  39. /// <returns>True if successful.</returns>
  40. bool SaveManifest(PluginManifest manifest, string path);
  41. /// <summary>
  42. /// Generates a manifest from repository data.
  43. /// </summary>
  44. /// <param name="packageInfo">The <see cref="PackageInfo"/> used to generate a manifest.</param>
  45. /// <param name="version">Version to be installed.</param>
  46. /// <param name="path">The path where to save the manifest.</param>
  47. /// <param name="status">Initial status of the plugin.</param>
  48. /// <returns>True if successful.</returns>
  49. Task<bool> PopulateManifest(PackageInfo packageInfo, Version version, string path, PluginStatus status);
  50. /// <summary>
  51. /// Imports plugin details from a folder.
  52. /// </summary>
  53. /// <param name="folder">Folder of the plugin.</param>
  54. void ImportPluginFrom(string folder);
  55. /// <summary>
  56. /// Disable the plugin.
  57. /// </summary>
  58. /// <param name="assembly">The <see cref="Assembly"/> of the plug to disable.</param>
  59. void FailPlugin(Assembly assembly);
  60. /// <summary>
  61. /// Disable the plugin.
  62. /// </summary>
  63. /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
  64. void DisablePlugin(LocalPlugin plugin);
  65. /// <summary>
  66. /// Enables the plugin, disabling all other versions.
  67. /// </summary>
  68. /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
  69. void EnablePlugin(LocalPlugin plugin);
  70. /// <summary>
  71. /// Attempts to find the plugin with and id of <paramref name="id"/>.
  72. /// </summary>
  73. /// <param name="id">Id of plugin.</param>
  74. /// <param name="version">The version of the plugin to locate.</param>
  75. /// <returns>A <see cref="LocalPlugin"/> if located, or null if not.</returns>
  76. LocalPlugin? GetPlugin(Guid id, Version? version = null);
  77. /// <summary>
  78. /// Removes the plugin.
  79. /// </summary>
  80. /// <param name="plugin">The plugin.</param>
  81. /// <returns>Outcome of the operation.</returns>
  82. bool RemovePlugin(LocalPlugin plugin);
  83. }
  84. }