public void Show()
        {
            var receiver = new Receiver();
            var command1 = new ConcreteCommand1(receiver);
            var command2 = new ConcreteCommand2(receiver);
            var invoker  = new Invoker();

            invoker.StoreAndExecute(command1);
            invoker.StoreAndExecute(command2);
        }
    public static void UnitTest()
    {
        Invoker theInvoker = new Invoker();

        Command theCommand = null;

        theCommand = new ConcreteCommand1(new Receiver1(), "HI");
        theInvoker.AddCommand(theCommand);

        theCommand = new ConcreteCommand2(new Receiver2(), 999);
        theInvoker.AddCommand(theCommand);

        theInvoker.ExecuteCommand();
    }
示例#3
0
    //
    void UnitTest()
    {
        Invoker theInvoker = new Invoker();

        Command theCommand = null;

        // 獎命令與執行結合
        theCommand = new ConcreteCommand1(new Receiver1(), "你好");
        theInvoker.AddCommand(theCommand);
        theCommand = new ConcreteCommand2(new Receiver2(), 999);
        theInvoker.AddCommand(theCommand);

        // 執行
        theInvoker.ExecuteCommand();
    }