static void Main() { // Create receiver, command, and invoker Receiver ReceiverObject = new Receiver(); //Creates a ConcreteCommand object and sets its receiver //Instantiates the command object and provides the information required to call the method at a later time. Command CommandObject = new ConcreteCommand(ReceiverObject); // Invoker - Asks the command to carry out the request. // Decides when the method should be called. Invoker InvokerObject = new Invoker(); InvokerObject.SetCommand(CommandObject); InvokerObject.ExecuteCommand(); // Wait for user Console.Read(); }
// Constructor takes the linked Receiver object, the same receiver object (called linked receiver) might be used by other concrete commands which will be passed from client. public ConcreteCommand(Receiver receiver) : base(receiver) { }
public Command(Receiver receiver) { this.receiver = receiver; }
public ConcreteCommand(Receiver receiver) : base(receiver) { }
public Command(Receiver receiver) { _receiver = receiver; }