mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Shared UI - Flattened namespaces Shared UI - General housekeeping Project - Code cleanup
26 lines
896 B
C#
26 lines
896 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)
|
|
{
|
|
var parentRequest = context.Request.ParentRequest;
|
|
if (parentRequest == null || typeof(Plugin).IsAssignableFrom(parentRequest.Service))
|
|
throw new ArtemisPluginException($"SettingsService can not be injected into a plugin. Inject {nameof(PluginSettings)} instead.");
|
|
|
|
return _instance;
|
|
}
|
|
}
|
|
} |