using System;
namespace Artemis.Core.Services;
///
/// Represents a web API controller registration.
///
/// The type of the web API controller.
public class WebApiControllerRegistration : WebApiControllerRegistration where T : class
{
internal WebApiControllerRegistration(IWebServerService webServerService, PluginFeature feature, string path) : base(webServerService, feature, typeof(T), path)
{
Factory = () => feature.Plugin.Resolve();
}
}
///
/// Represents a web API controller registration.
///
public abstract class WebApiControllerRegistration
{
private readonly IWebServerService _webServerService;
///
/// Creates a new instance of the class.
///
protected internal WebApiControllerRegistration(IWebServerService webServerService, PluginFeature feature, Type controllerType, string path)
{
_webServerService = webServerService;
Feature = feature;
ControllerType = controllerType;
Path = path;
Feature.Disabled += FeatureOnDisabled;
}
private void FeatureOnDisabled(object? sender, EventArgs e)
{
_webServerService.RemoveController(this);
Feature.Disabled -= FeatureOnDisabled;
}
///
/// Gets the type of the web API controller.
///
public Type ControllerType { get; }
///
/// Gets the plugin feature that provided the web API controller.
///
public PluginFeature Feature { get; }
///
/// Gets the path at which the controller is available.
///
public string Path { get; }
internal Func