コード例 #1
0
        private void CreateCompany(Command command)
        {
            var companyName = this.command.Args[0];
            var ceoName = this.command.Args[1] + ' ' + command.Args[2];
            var salary = decimal.Parse(this.command.Args[3]);

            CapitalismDatabase.CreateCompany(companyName, ceoName, salary);
        }
コード例 #2
0
        private void CreateDepartment(Command command)
        {
            var companyName = this.command.Args[0];
            var departmentName = this.command.Args[1];
            var managerName = this.command.Args[2] + ' ' + command.Args[3];

            if (command.Args.Length == 4)
            {
                var mainDepartmentName = this.command.Args[4];
                CapitalismDatabase.CreateDepartment(companyName, departmentName, managerName, mainDepartmentName);
            }
            else
            {
                CapitalismDatabase.CreateDepartment(companyName, departmentName, managerName);
            }
        }
コード例 #3
0
        public void ParseCommand(Command command)
        {
            switch (command.Type)
            {
                case "create-company":
                    CreateCompany(command);
                    break;

                case "create-department":
                    CreateDepartment(command);
                    break;

                default:
                    throw new InvalidOperationException("Invalid command.");
            }
        }
コード例 #4
0
 public CommandParser(Command command)
 {
     Command = command;
 }