예제 #1
0
        static void Main()
        {
            // Create receiver, command, and invoker
            Receiver ReceiverObject = new Receiver();

            //Creates a ConcreteCommand object and sets its receiver
            //Instantiates the command object and provides the information required to call the method at a later time.
            Command CommandObject = new ConcreteCommand(ReceiverObject);

            // Invoker - Asks the command to carry out the request.
            // Decides when the method should be called.
            Invoker InvokerObject = new Invoker();
            InvokerObject.SetCommand(CommandObject);
            InvokerObject.ExecuteCommand();

            // Wait for user
            Console.Read();
        }
        static void Main()
        {
            // Create receiver, command, and invoker
            Receiver ReceiverObject = new Receiver();

            //Creates a ConcreteCommand object and sets its receiver
            //Instantiates the command object and provides the information required to call the method at a later time.
            Command CommandObject = new ConcreteCommand(ReceiverObject);

            // Invoker - Asks the command to carry out the request.
            // Decides when the method should be called.
            Invoker InvokerObject = new Invoker();

            InvokerObject.SetCommand(CommandObject);
            InvokerObject.ExecuteCommand();

            // Wait for user
            Console.Read();
        }