Exemple #1
0
 static void Main(string[] args)
 {
     var bulb = new Bulb();
     var switch1 = new Switch(new OnCommand(bulb), new OffCommand(bulb));
     switch1.On();
     switch1.Off();
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            var bulb = new Bulb();

            var turnOn  = new TurnOn(bulb);
            var turnOff = new TurnOff(bulb);

            var remote = new RemoteControl();

            remote.Submit(turnOn);  // Bulb has been lit!
            remote.Submit(turnOff); // Darkness!

            Console.ReadLine();
        }
 public TurnOff(Bulb bulb)
 {
     mBulb = bulb ?? throw new ArgumentNullException("Bulb", "Bulb cannot be null");
 }
Exemple #4
0
 public OffCommand(Bulb bulb)
 {
     _bulb = bulb;
 }