2020-04-01 15:11:56 -04:00
|
|
|
|
using IW4MAdmin.Application.EventParsers;
|
|
|
|
|
using IW4MAdmin.Application.Factories;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
using IW4MAdmin.Application.Helpers;
|
2020-01-31 21:15:07 -05:00
|
|
|
|
using IW4MAdmin.Application.Migration;
|
2020-01-13 21:06:57 -05:00
|
|
|
|
using IW4MAdmin.Application.Misc;
|
2019-12-02 16:52:36 -05:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2018-04-09 15:17:10 -04:00
|
|
|
|
using SharedLibraryCore;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
using SharedLibraryCore.Configuration;
|
2020-01-17 18:31:53 -05:00
|
|
|
|
using SharedLibraryCore.Exceptions;
|
2020-01-11 21:32:27 -05:00
|
|
|
|
using SharedLibraryCore.Helpers;
|
2019-12-02 16:52:36 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2019-01-27 20:45:35 -05:00
|
|
|
|
using System;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
using System.Linq;
|
2018-04-23 01:43:48 -04:00
|
|
|
|
using System.Text;
|
2019-05-17 10:02:09 -04:00
|
|
|
|
using System.Threading;
|
2019-01-27 20:45:35 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2018-04-09 15:17:10 -04:00
|
|
|
|
|
2018-04-08 14:48:40 -04:00
|
|
|
|
namespace IW4MAdmin.Application
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-02-21 20:29:23 -05:00
|
|
|
|
public class Program
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-11 21:32:27 -05:00
|
|
|
|
public static BuildNumber Version { get; private set; } = BuildNumber.Parse(Utilities.GetVersionAsString());
|
2019-05-08 21:34:17 -04:00
|
|
|
|
public static ApplicationManager ServerManager;
|
|
|
|
|
private static Task ApplicationTask;
|
2020-01-11 21:32:27 -05:00
|
|
|
|
private static readonly BuildNumber _fallbackVersion = BuildNumber.Parse("99.99.99.99");
|
2020-01-31 21:15:07 -05:00
|
|
|
|
private static ServiceProvider serviceProvider;
|
2019-05-08 21:34:17 -04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// entrypoint of the application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static async Task Main()
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-12-31 21:52:19 -05:00
|
|
|
|
AppDomain.CurrentDomain.SetData("DataDirectory", Utilities.OperatingDirectory);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
|
2018-04-23 01:43:48 -04:00
|
|
|
|
Console.OutputEncoding = Encoding.UTF8;
|
2018-04-26 02:13:04 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
2017-11-19 01:44:11 -05:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
|
2015-08-17 16:38:42 -04:00
|
|
|
|
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.WriteLine(" IW4MAdmin");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine(" by RaidMax ");
|
2018-09-13 15:34:42 -04:00
|
|
|
|
Console.WriteLine($" Version {Utilities.GetVersionAsString()}");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-07-06 15:51:08 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
await LaunchAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// event callback executed when the control + c combination is detected
|
|
|
|
|
/// gracefully stops the server manager and waits for all tasks to finish
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private static async void OnCancelKey(object sender, ConsoleCancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ServerManager?.Stop();
|
|
|
|
|
await ApplicationTask;
|
|
|
|
|
}
|
2018-05-05 16:36:26 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// task that initializes application and starts the application monitoring and runtime tasks
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private static async Task LaunchAsync()
|
|
|
|
|
{
|
|
|
|
|
restart:
|
2020-01-31 21:15:07 -05:00
|
|
|
|
ITranslationLookup translationLookup = null;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
try
|
2015-07-06 15:51:08 -04:00
|
|
|
|
{
|
2020-02-03 09:21:42 -05:00
|
|
|
|
// do any needed housekeeping file/folder migrations
|
|
|
|
|
ConfigurationMigration.MoveConfigFolder10518(null);
|
|
|
|
|
ConfigurationMigration.CheckDirectories();
|
|
|
|
|
|
2020-01-13 21:06:57 -05:00
|
|
|
|
var services = ConfigureServices();
|
2020-01-31 21:15:07 -05:00
|
|
|
|
serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
ServerManager = (ApplicationManager)serviceProvider.GetRequiredService<IManager>();
|
2020-02-01 13:27:14 -05:00
|
|
|
|
translationLookup = serviceProvider.GetRequiredService<ITranslationLookup>();
|
2020-01-31 21:15:07 -05:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
ServerManager.Logger.WriteInfo(Utilities.CurrentLocalization.LocalizationIndex["MANAGER_VERSION"].FormatExt(Version));
|
2018-09-02 17:59:27 -04:00
|
|
|
|
|
2020-01-31 21:15:07 -05:00
|
|
|
|
await CheckVersion(translationLookup);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
await ServerManager.Init();
|
|
|
|
|
}
|
2018-05-08 00:58:46 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2020-01-31 21:15:07 -05:00
|
|
|
|
string failMessage = translationLookup == null ? "Failed to initalize IW4MAdmin" : translationLookup["MANAGER_INIT_FAIL"];
|
2020-04-01 15:11:56 -04:00
|
|
|
|
string exitMessage = translationLookup == null ? "Press enter to exit..." : translationLookup["MANAGER_EXIT"];
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.WriteLine(failMessage);
|
|
|
|
|
|
|
|
|
|
while (e.InnerException != null)
|
2018-04-19 01:48:14 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
e = e.InnerException;
|
2018-04-19 01:48:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-31 21:15:07 -05:00
|
|
|
|
if (e is ConfigurationException configException)
|
2020-01-17 18:31:53 -05:00
|
|
|
|
{
|
2020-02-03 09:21:42 -05:00
|
|
|
|
if (translationLookup != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(translationLookup[configException.Message].FormatExt(configException.ConfigurationFileName));
|
|
|
|
|
}
|
2020-01-31 21:15:07 -05:00
|
|
|
|
|
|
|
|
|
foreach (string error in configException.Errors)
|
2020-01-17 18:31:53 -05:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-31 21:15:07 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.WriteLine(exitMessage);
|
2020-04-01 15:11:56 -04:00
|
|
|
|
await Console.In.ReadAsync(new char[1], 0, 1);
|
2019-05-09 21:00:00 -04:00
|
|
|
|
return;
|
2019-05-08 21:34:17 -04:00
|
|
|
|
}
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ApplicationTask = RunApplicationTasksAsync();
|
|
|
|
|
await ApplicationTask;
|
|
|
|
|
}
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
catch { }
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
if (ServerManager.IsRestartRequested)
|
|
|
|
|
{
|
|
|
|
|
goto restart;
|
|
|
|
|
}
|
2020-01-31 21:15:07 -05:00
|
|
|
|
|
|
|
|
|
serviceProvider.Dispose();
|
2019-05-08 21:34:17 -04:00
|
|
|
|
}
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// runs the core application tasks
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private static async Task RunApplicationTasksAsync()
|
|
|
|
|
{
|
|
|
|
|
var webfrontTask = ServerManager.GetApplicationSettings().Configuration().EnableWebFront ?
|
2020-01-31 21:15:07 -05:00
|
|
|
|
WebfrontCore.Program.Init(ServerManager, serviceProvider, ServerManager.CancellationToken) :
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Task.CompletedTask;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
2019-05-17 10:02:09 -04:00
|
|
|
|
// we want to run this one on a manual thread instead of letting the thread pool handle it,
|
|
|
|
|
// because we can't exit early from waiting on console input, and it prevents us from restarting
|
|
|
|
|
var inputThread = new Thread(async () => await ReadConsoleInput());
|
|
|
|
|
inputThread.Start();
|
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
var tasks = new[]
|
|
|
|
|
{
|
2019-05-09 21:00:00 -04:00
|
|
|
|
ServerManager.Start(),
|
2019-05-08 21:34:17 -04:00
|
|
|
|
webfrontTask,
|
|
|
|
|
};
|
2015-08-22 02:04:30 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
await Task.WhenAll(tasks);
|
2017-06-12 13:50:00 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
ServerManager.Logger.WriteVerbose(Utilities.CurrentLocalization.LocalizationIndex["MANAGER_SHUTDOWN_SUCCESS"]);
|
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// checks for latest version of the application
|
|
|
|
|
/// notifies user if an update is available
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2020-01-31 21:15:07 -05:00
|
|
|
|
private static async Task CheckVersion(ITranslationLookup translationLookup)
|
2019-05-08 21:34:17 -04:00
|
|
|
|
{
|
|
|
|
|
var api = API.Master.Endpoint.Get();
|
2020-01-31 21:15:07 -05:00
|
|
|
|
var loc = translationLookup;
|
2015-08-22 02:04:30 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
var version = new API.Master.VersionInfo()
|
|
|
|
|
{
|
2020-01-11 21:32:27 -05:00
|
|
|
|
CurrentVersionStable = _fallbackVersion
|
2019-05-08 21:34:17 -04:00
|
|
|
|
};
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
try
|
|
|
|
|
{
|
2020-01-11 21:32:27 -05:00
|
|
|
|
version = await api.GetVersion(1);
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
catch (Exception e)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
ServerManager.Logger.WriteWarning(loc["MANAGER_VERSION_FAIL"]);
|
2018-04-09 15:17:10 -04:00
|
|
|
|
while (e.InnerException != null)
|
2018-03-13 20:12:24 -04:00
|
|
|
|
{
|
|
|
|
|
e = e.InnerException;
|
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
|
|
|
|
|
ServerManager.Logger.WriteDebug(e.Message);
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
2018-04-26 02:13:04 -04:00
|
|
|
|
|
2020-01-11 21:32:27 -05:00
|
|
|
|
if (version.CurrentVersionStable == _fallbackVersion)
|
2018-05-10 01:34:29 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
Console.WriteLine(loc["MANAGER_VERSION_FAIL"]);
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
2018-05-10 01:34:29 -04:00
|
|
|
|
}
|
2018-04-26 02:13:04 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
#if !PRERELEASE
|
|
|
|
|
else if (version.CurrentVersionStable > Version)
|
2018-10-05 23:10:39 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
2020-01-11 21:32:27 -05:00
|
|
|
|
Console.WriteLine($"IW4MAdmin {loc["MANAGER_VERSION_UPDATE"]} [v{version.CurrentVersionStable.ToString()}]");
|
|
|
|
|
Console.WriteLine(loc["MANAGER_VERSION_CURRENT"].FormatExt($"[v{Version.ToString()}]"));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
2018-10-05 23:10:39 -04:00
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
#else
|
|
|
|
|
else if (version.CurrentVersionPrerelease > Version)
|
|
|
|
|
{
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
2020-01-11 21:32:27 -05:00
|
|
|
|
Console.WriteLine($"IW4MAdmin-Prerelease {loc["MANAGER_VERSION_UPDATE"]} [v{version.CurrentVersionPrerelease.ToString()}-pr]");
|
|
|
|
|
Console.WriteLine(loc["MANAGER_VERSION_CURRENT"].FormatExt($"[v{Version.ToString()}-pr]"));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else
|
2018-10-05 23:10:39 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
|
|
|
Console.WriteLine(loc["MANAGER_VERSION_SUCCESS"]);
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
2018-10-05 23:10:39 -04:00
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// reads input from the console and executes entered commands on the default server
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private static async Task ReadConsoleInput()
|
|
|
|
|
{
|
|
|
|
|
string lastCommand;
|
|
|
|
|
var Origin = Utilities.IW4MAdminClient(ServerManager.Servers[0]);
|
2018-10-05 23:10:39 -04:00
|
|
|
|
|
2019-05-31 11:17:01 -04:00
|
|
|
|
try
|
2018-10-05 23:10:39 -04:00
|
|
|
|
{
|
2019-05-31 11:17:01 -04:00
|
|
|
|
while (!ServerManager.CancellationToken.IsCancellationRequested)
|
2019-05-08 21:34:17 -04:00
|
|
|
|
{
|
2020-04-01 15:11:56 -04:00
|
|
|
|
lastCommand = await Console.In.ReadLineAsync();
|
2019-05-31 11:17:01 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
if (lastCommand?.Length > 0)
|
|
|
|
|
{
|
2019-05-31 11:17:01 -04:00
|
|
|
|
if (lastCommand?.Length > 0)
|
2019-05-08 21:34:17 -04:00
|
|
|
|
{
|
2019-05-31 11:17:01 -04:00
|
|
|
|
GameEvent E = new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.Command,
|
|
|
|
|
Data = lastCommand,
|
|
|
|
|
Origin = Origin,
|
|
|
|
|
Owner = ServerManager.Servers[0]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ServerManager.GetEventHandler().AddEvent(E);
|
|
|
|
|
await E.WaitAsync(Utilities.DefaultCommandTimeout, ServerManager.CancellationToken);
|
|
|
|
|
Console.Write('>');
|
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-05 23:10:39 -04:00
|
|
|
|
}
|
2019-05-31 11:17:01 -04:00
|
|
|
|
catch (OperationCanceledException)
|
|
|
|
|
{ }
|
2015-08-17 16:38:42 -04:00
|
|
|
|
}
|
2019-12-02 16:52:36 -05:00
|
|
|
|
|
2020-01-13 21:06:57 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configures the dependency injection services
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static IServiceCollection ConfigureServices()
|
2019-12-02 16:52:36 -05:00
|
|
|
|
{
|
2020-02-11 17:44:06 -05:00
|
|
|
|
var defaultLogger = new Logger("IW4MAdmin-Manager");
|
|
|
|
|
var pluginImporter = new PluginImporter(defaultLogger);
|
|
|
|
|
|
2020-02-01 13:27:14 -05:00
|
|
|
|
var serviceCollection = new ServiceCollection();
|
|
|
|
|
serviceCollection.AddSingleton<IServiceCollection>(_serviceProvider => serviceCollection)
|
2020-01-31 21:15:07 -05:00
|
|
|
|
.AddSingleton(new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings") as IConfigurationHandler<ApplicationConfiguration>)
|
|
|
|
|
.AddSingleton(new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration") as IConfigurationHandler<CommandConfiguration>)
|
|
|
|
|
.AddSingleton(_serviceProvider => _serviceProvider.GetRequiredService<IConfigurationHandler<ApplicationConfiguration>>().Configuration())
|
2020-02-01 14:28:05 -05:00
|
|
|
|
.AddSingleton(_serviceProvider => _serviceProvider.GetRequiredService<IConfigurationHandler<CommandConfiguration>>().Configuration() ?? new CommandConfiguration())
|
2020-02-11 17:44:06 -05:00
|
|
|
|
.AddSingleton<ILogger>(_serviceProvider => defaultLogger)
|
2020-01-31 21:15:07 -05:00
|
|
|
|
.AddSingleton<IPluginImporter, PluginImporter>()
|
2020-01-26 19:06:50 -05:00
|
|
|
|
.AddSingleton<IMiddlewareActionHandler, MiddlewareActionHandler>()
|
2020-02-11 17:44:06 -05:00
|
|
|
|
.AddSingleton<IRConConnectionFactory, RConConnectionFactory>()
|
|
|
|
|
.AddSingleton<IGameServerInstanceFactory, GameServerInstanceFactory>()
|
|
|
|
|
.AddSingleton<IConfigurationHandlerFactory, ConfigurationHandlerFactory>()
|
2020-04-01 15:11:56 -04:00
|
|
|
|
.AddSingleton<IParserRegexFactory, ParserRegexFactory>()
|
|
|
|
|
.AddTransient<IParserPatternMatcher, ParserPatternMatcher>()
|
2020-01-26 19:06:50 -05:00
|
|
|
|
.AddSingleton(_serviceProvider =>
|
|
|
|
|
{
|
2020-01-31 21:15:07 -05:00
|
|
|
|
var config = _serviceProvider.GetRequiredService<IConfigurationHandler<ApplicationConfiguration>>().Configuration();
|
|
|
|
|
return Localization.Configure.Initialize(useLocalTranslation: config?.UseLocalTranslations ?? false,
|
|
|
|
|
customLocale: config?.EnableCustomLocale ?? false ? (config.CustomLocale ?? "en-US") : "en-US");
|
2020-02-01 13:27:14 -05:00
|
|
|
|
})
|
|
|
|
|
.AddSingleton<IManager, ApplicationManager>();
|
2020-01-26 19:06:50 -05:00
|
|
|
|
|
2020-02-11 17:44:06 -05:00
|
|
|
|
// register the native commands
|
|
|
|
|
foreach (var commandType in typeof(SharedLibraryCore.Commands.QuitCommand).Assembly.GetTypes()
|
|
|
|
|
.Where(_command => _command.BaseType == typeof(Command)))
|
|
|
|
|
{
|
|
|
|
|
defaultLogger.WriteInfo($"Registered native command type {commandType.Name}");
|
|
|
|
|
serviceCollection.AddSingleton(typeof(IManagerCommand), commandType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// register the plugin implementations
|
|
|
|
|
var pluginImplementations = pluginImporter.DiscoverAssemblyPluginImplementations();
|
|
|
|
|
foreach (var pluginType in pluginImplementations.Item1)
|
|
|
|
|
{
|
|
|
|
|
defaultLogger.WriteInfo($"Registered plugin type {pluginType.FullName}");
|
|
|
|
|
serviceCollection.AddSingleton(typeof(IPlugin), pluginType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// register the plugin commands
|
|
|
|
|
foreach (var commandType in pluginImplementations.Item2)
|
|
|
|
|
{
|
|
|
|
|
defaultLogger.WriteInfo($"Registered plugin command type {commandType.FullName}");
|
|
|
|
|
serviceCollection.AddSingleton(typeof(IManagerCommand), commandType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// register any script plugins
|
|
|
|
|
foreach (var scriptPlugin in pluginImporter.DiscoverScriptPlugins())
|
|
|
|
|
{
|
|
|
|
|
serviceCollection.AddSingleton(scriptPlugin);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-01 13:27:14 -05:00
|
|
|
|
return serviceCollection;
|
2019-12-02 16:52:36 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|