Files
Artemis/src/Artemis.Core/Ninject/SettingsServiceProvider.cs
T
SpoinkyNL 29d4db55db Core - Flattened namespaces
Shared UI - Flattened namespaces
Shared UI - General housekeeping
Project - Code cleanup
2020-09-01 00:14:08 +02:00

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;
}
}
}