static void Main(string[] args) { //命令模式 Receiver receiver = new Receiver(); Commandexe cmd = new ConcreteCommand(receiver); Invoke invoke = new Invoke(); invoke.SetCommand(cmd); invoke.ExecuteCommand(); Console.Read(); }
static void Main(string[] args) { Console.WriteLine("***Command Pattern Demo***\n"); Invoke invoker = new Invoke(); Receiver intendedreceiver = new Receiver(); MyUndoCommand undoCmd = new MyUndoCommand(intendedreceiver); invoker.SetCommand(undoCmd); invoker.ExecuteCommand(); MyRedoCommand redoCmd = new MyRedoCommand(intendedreceiver); invoker.SetCommand(redoCmd); invoker.ExecuteCommand(); }