mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
26 lines
908 B
C#
26 lines
908 B
C#
using Artemis.Core.Services;
|
|
using Ninject;
|
|
using Ninject.Activation;
|
|
|
|
namespace Artemis.Core.Ninject
|
|
{
|
|
internal class SettingsServiceProvider : Provider<ISettingsService>
|
|
{
|
|
private readonly SettingsService _instance;
|
|
|
|
public SettingsServiceProvider(IKernel kernel)
|
|
{
|
|
// This is not lazy, but the core is always going to be using this anyway
|
|
_instance = kernel.Get<SettingsService>();
|
|
}
|
|
|
|
protected override ISettingsService CreateInstance(IContext context)
|
|
{
|
|
IRequest parentRequest = context.Request.ParentRequest;
|
|
if (parentRequest == null || typeof(PluginFeature).IsAssignableFrom(parentRequest.Service))
|
|
throw new ArtemisPluginException($"SettingsService can not be injected into a plugin. Inject {nameof(PluginSettings)} instead.");
|
|
|
|
return _instance;
|
|
}
|
|
}
|
|
} |