static void Main(string[] args) { ISwitchable lamp = new Light(); ICommand openSwitchCommand = new OpenSwitchCommand(lamp); ICommand closeSwitchCommand = new CloseSwitchCommand(lamp); SwitchInvoker switchInvoker = new SwitchInvoker(openSwitchCommand, closeSwitchCommand); switchInvoker.Open(); switchInvoker.Close(); }
static void Main(string[] args) { ISwitchable switcher = new LightSwitcher(); ICommand on = new PowerOnCommand(switcher); ICommand off = new PowerOffCommand(switcher); var invoker = new SwitchInvoker(on, off); Console.WriteLine("Lights ON =>"); invoker.LightOn(); Console.WriteLine(); Console.WriteLine("Lights OFF =>"); invoker.LightOff(); Console.WriteLine(); Console.ReadKey(); }