Example #1
0
        public void Execute(string commandString)
        {
            bool isValid = false;

            string[] commandBits = commandString.Split(' ');
            if (commandBits.Any())
            {
                string commandType = commandBits[0].ToLower();
                switch (commandType)
                {
                case ClearCommand:
                    recorder.Clear();
                    isValid = true;
                    break;

                case DeleteCommand:
                    if (commandBits.Count() > 1)
                    {
                        recorder.DeleteByKey(commandBits[1]);
                        isValid = true;
                    }
                    break;

                case AddCommand:
                    if (commandBits.Count() > 2)
                    {
                        recorder.Add(commandBits[1], int.Parse(commandBits[2]));
                        isValid = true;
                    }
                    break;

                default:
                    recorder.RegisterInvalidCommand(commandString);
                    break;
                }
            }
        }