//Avoid coupling the sender of a request to its receiver by giving more than one //object chance to handle the request. static void Main(string[] _) { var lamp = new Lamp(); var turnOff = new TurnOff(lamp); var turnOn = new TurnOn(lamp); var remote = new RemoteControl(); remote.Submit(turnOff); remote.Submit(turnOn); Console.ReadKey(); }
static void Main() { var bulb = new Bulb(); var turnOn = new TurnOn(bulb); var turnOff = new TurnOff(bulb); var remote = new RemoteControl(); remote.Submit(turnOn); remote.Submit(turnOff); Console.ReadLine(); }
static void Main(string[] args) { IDevice bulb = new Bulb(); ICommand turnOn = new TurnOn(bulb); ICommand turnOff = new TurnOff(bulb); RemoteControl remote = new RemoteControl(); remote.submit(turnOn); remote.submit(turnOff); System.Console.ReadLine(); }
static void Main(string[] args) { IDevice bulb = new Bulb(); var bulbTurnOn = new TurnOn(bulb); var bulbTurnOff = new TurnOff(bulb); Remote remote = new Remote(); remote.Submit(bulbTurnOn); //remote.SubmitUndo(bulbTurnOn); remote.Submit(bulbTurnOff); 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); remote.Submit(turnOff); turnOff.Undo(); turnOn.Redo(); Console.ReadKey(); }