public void Execute()
 {
     if (CanExecute())
     {
         light.TurnOn();
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            var remote = new SimpleRemoteControl();

            remote.SetCommand(new LightOnCommand(new Light()));
            remote.ButtonWasPressed();

            remote.SetCommand(new GarageDoorOpenCommand(new GarageDoor()));
            remote.ButtonWasPressed();


            // LAMBDA STYLE
            Console.WriteLine("LAMBDA STYLE");
            var remoteControl   = new RemoteControl(); // invoker
            var livingRoomLight = new Light();         // reciever

            remoteControl.SetCommand(0, () => livingRoomLight.TurnOn(), () => livingRoomLight.TurnOff());

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
        }
Пример #3
0
 public void Execute()
 {
     _light.TurnOn();
 }