示例#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);
        }
示例#2
0
        private static void CommandPatternSection()
        {
            var customerManager = new CustomerManager();
            var button          = new Button(new AddCustomerCommand(customerManager));

            button.Click();
        }
示例#3
0
        private static void ExecuteCommand()
        {
            var customerService    = new CustomerService();
            var addCustomerCommand = new AddCustomerCommand(customerService);
            var button             = new Command.Button(addCustomerCommand);

            button.Click();
        }
示例#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();
        }