static void Main(string[] args) { Receiver receiver = new Receiver(); Command command = new ConcreteCommand(receiver); var results = command.Execute().Results; Console.WriteLine(results); bool condition = false; DelegateCommand delegateCommand = new DelegateCommand(() => Console.WriteLine("Hello World!"), () => condition); delegateCommand.Execute(); condition = true; delegateCommand.Execute(); }
static void Main(string[] args) { // Create receiver, command, and invoker Receiver receiver = new Receiver(); Command command = new ConcreteCommand(receiver); Invoker invoker = new Invoker(); // Set and execute command invoker.SetCommand(command); invoker.ExecuteCommand(); // Wait for user Console.Read(); }
// Constructor public Command(Receiver receiver) { this.receiver = receiver; }
// Constructor public ConcreteCommand(Receiver receiver) : base(receiver) { }
public Command(Receiver receiver, string statement) { _receiver = receiver; _statement = statement; }
public FistCommand(Receiver machine) : base(machine) { }
/// <summary> /// Initializes a new instance of the <see cref="CommandPattern.ConcreteCommand"/> class. /// </summary> /// <param name="receiver">The receiver to use.</param> public ConcreteCommand(Receiver receiver) : base(receiver) { Console.WriteLine("New command created"); }
public Command(Receiver receiver) { this.receiver = receiver; }
public Invoker() : base() { _receiver = new Receiver(); }
protected Command(Receiver receiver) =>
public Command(Receiver receiver) { Execute = receiver.Action; Redo = receiver.Action; Undo = receiver.Reverse; }