-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathScriptPluginFactory.cs
32 lines (27 loc) · 1.14 KB
/
ScriptPluginFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using IW4MAdmin.Application.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SharedLibraryCore.Interfaces;
namespace IW4MAdmin.Application.Plugin.Script;
public class ScriptPluginFactory : IScriptPluginFactory
{
private readonly IServiceProvider _serviceProvider;
public ScriptPluginFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public object CreateScriptPlugin(Type type, string fileName)
{
if (type == typeof(IPlugin))
{
return new ScriptPlugin(_serviceProvider.GetRequiredService<ILogger<ScriptPlugin>>(),
fileName);
}
return new ScriptPluginV2(fileName, _serviceProvider.GetRequiredService<ILogger<ScriptPluginV2>>(),
_serviceProvider.GetRequiredService<IScriptPluginServiceResolver>(),
_serviceProvider.GetRequiredService<IScriptCommandFactory>(),
_serviceProvider.GetRequiredService<IConfigurationHandlerV2<ScriptPluginConfiguration>>(),
_serviceProvider.GetRequiredService<IInteractionRegistration>());
}
}