private async Task ResolveCommand(string inputTrigger) { if (!this.Commands.ContainsKey(inputTrigger)) { this.Context.Output.Clear(); (this.Context.Output as IConsoleOutput).WriteLine("This command does not exist.", ConsoleColor.Red); return; } CommandPrescription prescription = this.Commands[inputTrigger]; if (prescription != null) { if (prescription.IsProcessRefreshing) { await Gatherer.Run(Context, prescription.IsRefreshingBlacklistedOnly); } if (!typeof(IGatherer).IsAssignableFrom(prescription.CommandType)) { ICommand command = (ICommand)Activator.CreateInstance(prescription.CommandType); await command.Run(Context); } } }
protected void HasCommand <T>(string inputTrigger, bool refreshProcesses = false, bool refreshBlacklistedOnly = false) where T : ICommand { CommandPrescription command = new CommandPrescription(); if (this.Commands.ContainsKey(inputTrigger)) { command = this.Commands[inputTrigger]; } else { this.Commands.Add(inputTrigger, command); } command.IsProcessRefreshing = refreshProcesses; command.IsRefreshingBlacklistedOnly = refreshBlacklistedOnly; command.CommandType = typeof(T); }