private static void Main(string[] args) { var invoker = new Invoker(); var receiver = new Receiver(); ICommand command1 = new CommandOne(receiver); ICommand command2 = new CommandTwo(receiver); ICommand command3 = new CommandThree(receiver); invoker.InvokeCommand(command1); Console.WriteLine(); invoker.InvokeCommand(command2); Console.WriteLine(); invoker.InvokeCommand(command3); Console.ReadKey(); }
static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; var sender = new Sender(); // создадим получателя var receiver = new Receiver(); // создадим команду var commandOne = new CommandOne(receiver); // инициализация команды sender.SetCommand(commandOne); // выполнение sender.Run(); }