1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.Core/Services/WebServer/WebModuleRegistration.cs
Robert 3b4194cb9d Plugins - Ported prerequisites UI
Scripting - Ported scripting UI
2022-07-10 23:25:34 +02:00

34 lines
1.2 KiB
C#

using System;
using EmbedIO;
using Ninject;
namespace Artemis.Core.Services
{
internal class WebModuleRegistration
{
public PluginFeature Feature { get; }
public Type? WebModuleType { get; }
public Func<IWebModule>? Create { get; }
public WebModuleRegistration(PluginFeature feature, Type webModuleType)
{
Feature = feature ?? throw new ArgumentNullException(nameof(feature));
WebModuleType = webModuleType ?? throw new ArgumentNullException(nameof(webModuleType));
}
public WebModuleRegistration(PluginFeature feature, Func<IWebModule> create)
{
Feature = feature ?? throw new ArgumentNullException(nameof(feature));
Create = create ?? throw new ArgumentNullException(nameof(create));
}
public IWebModule CreateInstance()
{
if (Create != null)
return Create();
if (WebModuleType != null)
return (IWebModule) Feature.Plugin.Kernel!.Get(WebModuleType);
throw new ArtemisCoreException("WebModuleRegistration doesn't have a create function nor a web module type :(");
}
}
}