Exemplo n.º 1
0
        public RobotCommandResponse ProcessCommand(RobotCommand command)
        {
            var commandHandler = _commandHandlers.FirstOrDefault(x => x.Supports(command.CommandType));

            if (commandHandler == null)
            {
                return(new RobotCommandResponse(RobotResponseType.Unknown));
            }

            return(commandHandler.HandleCommand(command, _stateManager.Robot, _stateManager.Surface));
        }
Exemplo n.º 2
0
        public bool TryParse(string input, out RobotCommand command)
        {
            command = null;

            if (string.IsNullOrWhiteSpace(input))
            {
                return(false);
            }

            var inputArray = input.Split(new[] { ' ' }, 2);

            if (!Enum.TryParse <RobotCommandType>(inputArray[0], true, out var commandType))
            {
                return(false);
            }

            command = new RobotCommand
            {
                CommandType        = commandType,
                SecondaryArguments = inputArray.Length > 1 ? inputArray[1] : null
            };
            return(true);
        }