예제 #1
0
        public static ICommand CreateCommand(string argument)
        {
            string[] args = argument.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ICommand command = null;
            switch (args[0])
            {
                case "/?":
                case "/help":
                case "-help":
                    {
                        command = new HelpCommand(args);
                        break;
                    }
                case "-key":
                    {
                        command = new KeyCommand(args);
                        break;
                    }
                case "-ping":
                    {
                        command = new PingCommand(args);
                        break;
                    }
                case "-print":
                    {
                        command = new PrintCommand(args);
                        break;
                    }
                case "-setuser":
                    {
                        command = new SetUserCommand(args);
                        break;
                    }
                case "-getuser":
                    {
                        command = new GetUserCommand(args);
                        break;
                    }
                case "-exit":
                    {
                        command = new ExitCommand(args);
                        break;
                    }
                default:
                    {
                        command = new UnknownCommand(args);
                        break;
                    }
            }

            return command;
        }