public SlateBotProgram(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; controller = new SlateBotController(); lastExitCode = ExitCodes.Success; if (args.Length > 1) { Enum.TryParse <ExitCodes>(args[1], out lastExitCode); } }
public CommandController(SlateBotController controller) { this.controller = controller ?? throw new ArgumentNullException(nameof(controller)); this.commandHandlers = new Dictionary <CommandHandlerType, ICommandHandler>(); this.commands = new Dictionary <Languages, List <Command> >(); this.synchronizationContext = SynchronizationContext.Current; // Get all ICommandHandler in the assembly and instantiate them foreach (var commandHandlerType in Assembly .GetExecutingAssembly() .GetTypes() .Where(t => t.GetInterfaces().Contains(typeof(ICommandHandler)))) { var handler = (ICommandHandler)Activator.CreateInstance(commandHandlerType); if (commandHandlers.TryGetValue(handler.CommandHandlerType, out ICommandHandler dummy)) { controller.ErrorLogger.LogError(new Error(ErrorCode.CommandHandlerNotImplemented, ErrorSeverity.Error, "Duplicate command handler found: " + handler.CommandHandlerType + " in type " + handler.GetType())); } // Add it to the dictionary. commandHandlers[handler.CommandHandlerType] = handler; } // Check if any are missing. foreach (CommandHandlerType cht in Enum.GetValues(typeof(CommandHandlerType))) { if (!commandHandlers.TryGetValue(cht, out ICommandHandler dummy)) { if (cht != CommandHandlerType.Unknown) { controller.ErrorLogger.LogError(new Error(ErrorCode.CommandHandlerNotImplemented, ErrorSeverity.Warning, cht.ToString())); } } } }
public UpdateController(SlateBotController controller) { this.controller = controller ?? throw new ArgumentNullException(nameof(controller)); preppedXMLs = new List <Tuple <Languages, string> >(); preppedProgramFiles = new List <string>(); }