mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-30 02:52:27 -04:00
Removing UnityContainer and fixing service loading
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Unity;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
@@ -59,30 +58,14 @@ namespace Kyoo.Controllers
|
||||
/// <summary>
|
||||
/// A configure method that will be run on plugin's startup.
|
||||
/// </summary>
|
||||
/// <param name="container">A unity container to register new services.</param>
|
||||
/// <param name="services">A service container to register new services.</param>
|
||||
/// <param name="availableTypes">The list of types that are available for this instance. This can be used
|
||||
/// for conditional type. See <see cref="ProviderCondition.Has(System.Type,System.Collections.Generic.ICollection{System.Type})"/>
|
||||
/// or <see cref="ProviderCondition.Has(System.Collections.Generic.ICollection{System.Type},System.Collections.Generic.ICollection{System.Type})"/>></param>
|
||||
void Configure(IUnityContainer container, ICollection<Type> availableTypes) {}
|
||||
/// or <see cref="ProviderCondition.Has(System.Collections.Generic.ICollection{System.Type},System.Collections.Generic.ICollection{System.Type})"/>>
|
||||
/// You can't simply check on the service collection because some dependencies might be registered after your plugin.
|
||||
/// </param>
|
||||
void Configure(IServiceCollection services, ICollection<Type> availableTypes);
|
||||
|
||||
/// <summary>
|
||||
/// An optional configure method that will be run on plugin's startup.
|
||||
/// This method may be used instead or with the
|
||||
/// <see cref="Configure(Unity.IUnityContainer,System.Collections.Generic.ICollection{System.Type})"/> method
|
||||
/// if you use a library that configure itself with a <see cref="IServiceCollection"/>.
|
||||
/// Every service put in this container will be registered to the unity container after this method.
|
||||
/// </summary>
|
||||
/// <param name="services">An empty service container to register new services.</param>
|
||||
/// <param name="availableTypes">The list of types that are available for this instance. This can be used
|
||||
/// for conditional type. See <see cref="ProviderCondition.Has(System.Type,System.Collections.Generic.ICollection{System.Type})"/>
|
||||
/// or <see cref="ProviderCondition.Has(System.Collections.Generic.ICollection{System.Type},System.Collections.Generic.ICollection{System.Type})"/>></param>
|
||||
/// <returns>You should return the <see cref="services"/> parameter or another container if you want.
|
||||
/// This container will be added to Kyoo's unity container.</returns>
|
||||
IServiceCollection Configure(IServiceCollection services, ICollection<Type> availableTypes)
|
||||
{
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An optional configuration step to allow a plugin to change asp net configurations.
|
||||
/// WARNING: This is only called on Kyoo's startup so you must restart the app to apply this changes.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Kyoo.Models.Exceptions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
@@ -29,11 +31,26 @@ namespace Kyoo.Controllers
|
||||
/// </summary>
|
||||
/// <returns>All plugins currently loaded.</returns>
|
||||
public ICollection<IPlugin> GetAllPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Load plugins and their dependencies from the plugin directory.
|
||||
/// </summary>
|
||||
/// <param name="plugins">
|
||||
/// An initial plugin list to use.
|
||||
/// You should not try to put plugins from the plugins directory here as they will get automatically loaded.
|
||||
/// </param>
|
||||
public void LoadPlugins(ICollection<IPlugin> plugins);
|
||||
|
||||
/// <summary>
|
||||
/// Configure services adding or removing services as the plugins wants.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to populate</param>
|
||||
public void ConfigureServices(IServiceCollection services);
|
||||
|
||||
/// <summary>
|
||||
/// Load new plugins from the plugin directory.
|
||||
/// Configure an asp net application applying plugins policies.
|
||||
/// </summary>
|
||||
/// <exception cref="MissingDependencyException">If a plugin can't be loaded because a dependency can't be resolved.</exception>
|
||||
public void ReloadPlugins();
|
||||
/// <param name="app">The asp net application to configure</param>
|
||||
public void ConfigureAspnet(IApplicationBuilder app);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user