Merge pull request #4253 from BaronGreenback/fordiscussion

DI in plugins
This commit is contained in:
Bond-009
2020-11-15 13:29:04 +01:00
committed by GitHub
6 changed files with 93 additions and 54 deletions

View File

@@ -83,16 +83,6 @@ namespace MediaBrowser.Common.Plugins
{
}
/// <inheritdoc />
public virtual void RegisterServices(IServiceCollection serviceCollection)
{
}
/// <inheritdoc />
public virtual void UnregisterServices(IServiceCollection serviceCollection)
{
}
/// <inheritdoc />
public void SetAttributes(string assemblyFilePath, string dataFolderPath, Version assemblyVersion)
{
@@ -185,6 +175,11 @@ namespace MediaBrowser.Common.Plugins
/// <value>The type of the configuration.</value>
public Type ConfigurationType => typeof(TConfigurationType);
/// <summary>
/// Gets or sets the event handler that is triggered when this configuration changes.
/// </summary>
public EventHandler<BasePluginConfiguration> ConfigurationChanged { get; set; }
/// <summary>
/// Gets the name the assembly file.
/// </summary>
@@ -280,6 +275,8 @@ namespace MediaBrowser.Common.Plugins
Configuration = (TConfigurationType)configuration;
SaveConfiguration();
ConfigurationChanged.Invoke(this, configuration);
}
/// <inheritdoc />

View File

@@ -62,18 +62,6 @@ namespace MediaBrowser.Common.Plugins
/// Called when just before the plugin is uninstalled from the server.
/// </summary>
void OnUninstalling();
/// <summary>
/// Registers the plugin's services to the service collection.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
void RegisterServices(IServiceCollection serviceCollection);
/// <summary>
/// Unregisters the plugin's services from the service collection.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
void UnregisterServices(IServiceCollection serviceCollection);
}
public interface IHasPluginConfiguration

View File

@@ -0,0 +1,19 @@
namespace MediaBrowser.Common.Plugins
{
using Microsoft.Extensions.DependencyInjection;
/// <summary>
/// Defines the <see cref="IPluginServiceRegistrator" />.
/// </summary>
public interface IPluginServiceRegistrator
{
/// <summary>
/// Registers the plugin's services with the service collection.
/// </summary>
/// <remarks>
/// This interface is only used for service registration and requires a parameterless constructor.
/// </remarks>
/// <param name="serviceCollection">The service collection.</param>
void RegisterServices(IServiceCollection serviceCollection);
}
}