using System; using JetBrains.Annotations; using Microsoft.AspNetCore.Builder; using Unity; namespace Kyoo.Controllers { /// /// A common interface used to discord plugins /// /// You can inject services in the IPlugin constructor. /// You should only inject well known services like an ILogger, IConfiguration or IWebHostEnvironment. [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] public interface IPlugin { /// /// A slug to identify this plugin in queries. /// string Slug { get; } /// /// The name of the plugin /// string Name { get; } /// /// The description of this plugin. This will be displayed on the "installed plugins" page. /// string Description { get; } /// /// A list of services that are provided by this service. This allow other plugins to declare dependencies. /// /// /// You should put the type's interface that will be register in configure. /// Type[] Provides { get; } /// /// 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. /// /// /// Put here the most complete type that are needed for your plugin to work. If you need a LibraryManager, /// put typeof(ILibraryManager). /// Type[] Requires { get; } /// /// True if this plugin is needed to start Kyoo. If this is true and a dependency could not be met, app startup /// will be canceled. If this is false, Kyoo's startup will continue without enabling this plugin. /// bool IsRequired { get; } /// /// A configure method that will be run on plugin's startup. /// /// A unity container to register new services. void Configure(IUnityContainer container); /// /// 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. /// /// The Asp.Net application builder. On most case it is not needed but you can use it to add asp net functionalities. void ConfigureAspNet(IApplicationBuilder app) {} } }