static void CommandPattern() { Console.WriteLine("\n\nCommandPattern Pattern"); var history = new History(); var exampleService = new ExampleService("Initial value"); var exampleCommand = new ExampleCommand(history, exampleService); var undoCommand = new UndoCommand <string>(history); Console.WriteLine(exampleService.GetContent()); exampleCommand.Execute(); Console.WriteLine(exampleService.GetContent()); undoCommand.Execute(); Console.WriteLine(exampleService.GetContent()); }