Reworking the plugin interface and moving the database to an external dll

This commit is contained in:
Zoe Roux
2021-04-28 23:40:22 +02:00
parent b7294114b9
commit 833447ded8
21 changed files with 365 additions and 2360 deletions
+32 -12
View File
@@ -1,8 +1,14 @@
using JetBrains.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Unity;
namespace Kyoo.Controllers
{
/// <summary>
/// A common interface used to discord plugins
/// </summary>
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public interface IPlugin
{
/// <summary>
@@ -19,21 +25,35 @@ namespace Kyoo.Controllers
/// The description of this plugin. This will be displayed on the "installed plugins" page.
/// </summary>
string Description { get; }
/// <summary>
/// A configure method that will be runned on plugin's startup.
/// A list of services that are provided by this service. This allow other plugins to declare dependencies.
/// </summary>
/// <remarks>
/// You can have use any services as parameter, they will be injected from the service provider
/// You can add managed types or any type you like using the IUnityContainer like so:
/// <code>
/// public static void Configure(IUnityContainer services)
/// {
/// services.AddTask&lt;MyTask&gt;()
/// }
/// </code>
/// The format should be the name of the interface ':' and the name of the implementation.
/// For a plugins that provide a new service named IService with a default implementation named Koala, that would
/// be "IService:Koala".
/// </remarks>
static void Configure() { }
string[] Provides { get; }
/// <summary>
/// A list of services that are required by this service.
/// The Core will warn the user that this plugin can't be loaded if a required service is not found.
/// </summary>
/// <remarks>
/// This is the same format as <see cref="Provides"/> but you may leave a blank implementation's name if you don't need a special one.
/// For example, if you need a service named IService but you don't care what implementation it will be, you can use
/// "IService:"
/// </remarks>
string[] Requires { get; }
/// <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="config">The configuration, if you need values at config time (database connection strings...)</param>
/// <param name="app">The Asp.Net application builder. On most case it is not needed but you can use it to add asp net functionalities.</param>
/// <param name="debugMode">True if the app should run in debug mode.</param>
void Configure(IUnityContainer container, IConfiguration config, IApplicationBuilder app, bool debugMode);
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Kyoo.Controllers
/// <param name="arguments">A list of arguments to pass to the task. An automatic conversion will be made if arguments to not fit.</param>
/// <exception cref="ArgumentException">If the number of arguments is invalid or if an argument can't be converted.</exception>
/// <exception cref="ItemNotFound">The task could not be found.</exception>
void StartTask(string taskSlug, Dictionary<string, object> arguments);
void StartTask(string taskSlug, Dictionary<string, object> arguments = null);
/// <summary>
/// Get all currently running tasks