Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 // Constructor
 public Command(Receiver receiver)
 {
     this.receiver = receiver;
 }
 // Constructor
 public ConcreteCommand(Receiver receiver)
     : base(receiver)
 {
 }
Ejemplo n.º 5
0
 public Command(Receiver receiver, string statement)
 {
     _receiver = receiver;
     _statement = statement;
 }
Ejemplo n.º 6
0
 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");
 }
Ejemplo n.º 8
0
 public Command(Receiver receiver)
 {
     this.receiver = receiver;
 }
Ejemplo n.º 9
0
 public Invoker()
     : base()
 {
     _receiver = new Receiver();
 }
Ejemplo n.º 10
0
 protected Command(Receiver receiver) =>
Ejemplo n.º 11
0
 public Command(Receiver receiver)
 {
     Execute = receiver.Action;
     Redo    = receiver.Action;
     Undo    = receiver.Reverse;
 }