コード例 #1
0
 public Command GetCommand(string arguments)
 {
     if (!string.IsNullOrEmpty(arguments))
     {
         string          newName = arguments.Split(' ').First();
         string          newArgs = arguments.Substring(newName.Length).Trim();
         ICommandMatcher match   = GarminCommands.Find(m => m.IsMatch(newName));
         if (match != null)
         {
             return(match.GetCommand(newArgs));
         }
         return(Commands.Concatenate(
                    Commands.Unknown,
                    GarminCommands.Find(m => m.IsMatch("help")).GetCommand(string.Empty)
                    ));
     }
     return(Commands.Empty);
 }
コード例 #2
0
        Command Read()
        {
            string commandLine = Input.ReadLine().Trim();

            if (!string.IsNullOrEmpty(commandLine))
            {
                string commandName = commandLine.Split(' ').First();
                string arguments   = commandLine.Substring(commandName.Length).Trim();

                ICommandMatcher match = CommandList.Find(m => m.IsMatch(commandName));
                if (match != null)
                {
                    return(match.GetCommand(arguments));
                }
                return(Commands.Unknown);
            }
            return(Commands.Empty);
        }