private IExecutable ParseCommand(string input, string command, string[] data) { var parametersForConstruction = new object[] { input, data }; var typeOfCommand = Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.GetCustomAttributes().Any(a => a.GetType() == typeof(AliasAttribute))) .FirstOrDefault(type => type.GetCustomAttribute <AliasAttribute>(false).Equals(command)); var commandInstance = container.CreateAndInject(typeOfCommand, parametersForConstruction) as IExecutable; return(commandInstance); }
public IExecutable InterpretCommand(string[] data, string commandName) { //Get the class which maches the command name with ignred casing var commandClass = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => string.Compare(t.Name, commandName, true) == 0); if (commandClass is null) { throw new InvalidOperationException("Invalid command!"); } var commandInstance = iocc.CreateAndInject(commandClass, new object[] { data }); return(commandInstance as IExecutable); }