Exemplo n.º 1
0
        private static void UndoableCommandPattern()
        {
            var document = new Document {
                Content = "Some content"
            };

            Console.WriteLine("Before");
            Console.WriteLine(document.Content);

            var history     = new CommandHistory();
            var boldCommand = new BoldCommand(document, history);
            var button      = new Button(boldCommand);

            button.Click();

            Console.WriteLine("After");
            Console.WriteLine(document.Content);


            Console.WriteLine("After Undo");
            var undoCommand = new UndoCommand(history);

            undoCommand.Execute();

            Console.WriteLine(document.Content);
        }
Exemplo n.º 2
0
        private static void CommandPatternSection()
        {
            var customerManager = new CustomerManager();
            var button          = new Button(new AddCustomerCommand(customerManager));

            button.Click();
        }
Exemplo n.º 3
0
        private static void ExecuteCommand()
        {
            var customerService    = new CustomerService();
            var addCustomerCommand = new AddCustomerCommand(customerService);
            var button             = new Command.Button(addCustomerCommand);

            button.Click();
        }
Exemplo n.º 4
0
        private static void CompositeCommandPatternSection()
        {
            var compositeCommand = new CompositeCommand();

            compositeCommand.Commands.Add(new AddFilterCommand());
            compositeCommand.Commands.Add(new RemoveBlurCommand());
            // compositeCommand.Execute();

            var button = new Button(compositeCommand);

            button.Click();
        }