public static void Run()
        {
            var cusService    = new CustomerService();
            var addCusCommand = new AddCustomerCommand(cusService);
            var addJohnBtn    = new CustomButton(addCusCommand, new CustomerModel {
                Id = 1, Age = 20, Name = "John"
            });
            var addDakeBtn = new CustomButton(addCusCommand, new CustomerModel {
                Id = 2, Age = 25, Name = "Dake"
            });

            addJohnBtn.Click();
            addDakeBtn.Click();
            addCusCommand.ExecuteUndo();

            var compoCommand = new CompositCommand();
            var addKimCmd    = compoCommand.AddCommand(new AddCustomerCommand(cusService,
                                                                              new CustomerModel {
                Id = 3, Age = 28, Name = "Kim"
            }));
            var addJamesCmd = compoCommand.AddCommand(new AddCustomerCommand(cusService,
                                                                             new CustomerModel {
                Id = 4, Age = 18, Name = "James"
            }));

            compoCommand.AddCommand(new AddCustomerCommand(cusService,
                                                           new CustomerModel {
                Id = 5, Age = 18, Name = "Boy"
            }));
            compoCommand.AddCommand(new DeleteCustomerCommand(cusService, new CustomerModel()
            {
                Id = 3
            }));

            compoCommand.AddCommand(addJamesCmd, true);

            var compoBtn = new CustomButton(compoCommand, null);

            compoBtn.Click();

            cusService.ShowAllCustomer();
        }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            if (button == Buttons.PLAY || button == Buttons.QUIT)
            {
                button = Buttons.BREAKER;
            }
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            if (button == Buttons.BREAKER)
            {
                button = Buttons.PLAY;
            }
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (button == Buttons.PLAY)
            {
                button = Buttons.QUIT;
            }
            else if (button == Buttons.QUIT)
            {
                button = Buttons.PLAY;
            }
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (button == Buttons.PLAY)
            {
                button = Buttons.QUIT;
            }
            else if (button == Buttons.QUIT)
            {
                button = Buttons.PLAY;
            }
        }

        play.over    = false;
        quit.over    = false;
        breaker.over = false;
        switch (button)
        {
        case Buttons.PLAY:
            play.over = true;
            selection = play;
            break;

        case Buttons.QUIT:
            quit.over = true;
            selection = quit;
            break;

        case Buttons.BREAKER:
            breaker.over = true;
            selection    = breaker;
            break;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            selection.click = true;
            selection.Click();
        }
        else if (Input.GetKeyUp(KeyCode.Return))
        {
            selection.click = false;
        }
    }