public static CommandMapping FromTokens(string[] tokens) { var commandLetter = (CommandType)Enum.Parse(typeof(CommandType), tokens[0]); int commandNumber = int.Parse(tokens[1]); var type = CommandReflection.GetCommandObjectType(commandLetter, commandNumber); if (type == null) { throw new Exception("No mapping defined for these tokens"); } return(FromTokens(type, tokens)); }
public static CommandBase FromTokens(string[] tokens, bool useMappedCommands = true) { if (useMappedCommands) { var commandLetter = (CommandType)Enum.Parse(typeof(CommandType), tokens[0]); int commandNumber = int.Parse(tokens[1]); var type = CommandReflection.GetCommandObjectType(commandLetter, commandNumber); if (type != null) { return(CommandMapping.FromTokens(tokens)); } } return(Command.FromTokens(tokens)); }