コード例 #1
0
        /// <summary>
        /// [Deprecated] This loader version has only 1 slot
        /// </summary>
        public void RunSimpleTest()
        {
            SimpleRemoteControl remote = new SimpleRemoteControl(); //Invoker

            Light           light    = new Light("Kitchen");        //Receiver
            LightOnCommand  lightOn  = new LightOnCommand(light);   //Concrete Command + setting the receiver, which is passed as a parameter
            LightOffCommand lightOff = new LightOffCommand(light);

            GarageDoor            garageDoor = new GarageDoor("");
            GarageDoorOpenCommand garageUp   = new GarageDoorOpenCommand(garageDoor);

            remote.Command = lightOn; //SetCommand [as it is the invoker]
            remote.ButtonPress();     //Finally Execute [as it is the invoker]

            remote.Command = garageUp;
            remote.ButtonPress();

            remote.Command = lightOff;
            remote.ButtonPress();
        }