public static CommandInstance ReadCommand(string[] arguments, ref int nextIndex) { if (arguments.Length == 0 || arguments.Length <= nextIndex) { return(null); } List <ConsoleCommand> availableCommandList = new List <ConsoleCommand>(); availableCommandList.Add(new ListDevicesCommand()); availableCommandList.Add(new ConfigureCommand()); availableCommandList.Add(new ServiceCommand()); availableCommandList.Add(new ReportCommand()); availableCommandList.Add(new TestingCommands()); foreach (ConsoleCommand command in availableCommandList) { if (command.IsMatchName(arguments[nextIndex])) { Logger.GetInstance().Trace("ReadCommand Found matched ConsoleCommand: " + command.GetLongName()); nextIndex++; CommandInstance instance = command.GenerateInstance(arguments, ref nextIndex); return(instance); } } return(null); }
public override CommandInstance GenerateInstance(string[] arguments, ref int nextIndex) { if (arguments.Length <= nextIndex) { throw new TargetExecutionException(DaemonErrorCode.COMMAND_PARAM_ERROR, "Argument Not Correct for Configure Command."); } CommandInstance instance = new CommandInstance(this); instance.Parameter = arguments[nextIndex++]; return(instance); }
public static List <CommandInstance> ParseCommands(string[] arguments) { List <CommandInstance> resultInstanceList = new List <CommandInstance>(); int index = 0; while (true) { CommandInstance instance = ReadCommand(arguments, ref index); if (instance == null) { break; } resultInstanceList.Add(instance); } return(resultInstanceList); }
public override CommandInstance GenerateInstance(string[] arguments, ref int nextIndex) { CommandInstance instance = new CommandInstance(this); return(instance); }