IW4M-Admin/Application/Factories/ScriptCommandFactory.cs

43 lines
1.6 KiB
C#
Raw Normal View History

2023-04-04 19:24:13 -04:00
using SharedLibraryCore;
using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
2023-04-04 19:24:13 -04:00
using Data.Models;
using Data.Models.Client;
2023-04-04 19:24:13 -04:00
using IW4MAdmin.Application.Plugin.Script;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace IW4MAdmin.Application.Factories
{
/// <summary>
/// implementation of IScriptCommandFactory
/// </summary>
public class ScriptCommandFactory : IScriptCommandFactory
{
private readonly CommandConfiguration _config;
private readonly ITranslationLookup _transLookup;
private readonly IServiceProvider _serviceProvider;
public ScriptCommandFactory(CommandConfiguration config, ITranslationLookup transLookup, IServiceProvider serviceProvider)
{
_config = config;
_transLookup = transLookup;
_serviceProvider = serviceProvider;
}
/// <inheritdoc/>
public IManagerCommand CreateScriptCommand(string name, string alias, string description, string permission,
2023-04-04 19:24:13 -04:00
bool isTargetRequired, IEnumerable<CommandArgument> args, Func<GameEvent, Task> executeAction, IEnumerable<Reference.Game> supportedGames)
{
var permissionEnum = Enum.Parse<EFClient.Permission>(permission);
2023-04-04 19:24:13 -04:00
return new ScriptCommand(name, alias, description, isTargetRequired, permissionEnum, args, executeAction,
_config, _transLookup, _serviceProvider.GetRequiredService<ILogger<ScriptCommand>>(), supportedGames);
}
}
}