示例#1
0
        public void AcceptCommand()
        {
            Console.Write("Type Command : ");
            var command = Console.ReadLine();

            if (command.Equals("--help"))
            {
                ShowCommands();
                AcceptCommand();
                return;
            }
            ICounter counter = PickCounterFromCommand(command);

            if (counter == null)
            {
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }

            switch (command.Split(' ').First().First())
            {
            case '+':
                counterService.Increment(counter, command.Split(' ').First().Length);
                break;

            case '-':
                counterService.Decrement(counter, command.Split(' ').First().Length);
                break;

            case 'a':
                counterService.Add(counter);
                break;

            case 'd':
                counterService.Delete(counter);
                break;

            default:
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }
        }