public static void Main() { new_Console = new Background_Color(new New_Console()); new_Console = new Text_Color(new_Console); new_Console.WriteLine("Decorator Pattern\n"); IComponent component = new Component(); Display("1. Basic component: ", component); Display("2. A-decorated : ", new DecoratorA(component)); Display("3. B-decorated : ", new DecoratorB(component)); Display("4. B-A-decorated : ", new DecoratorB( new DecoratorA(component))); // Explicit DecoratorB DecoratorB b = new DecoratorB(new Component()); Display("5. A-B-decorated : ", new DecoratorA(b)); // Invoking its added state and added behavior new_Console.WriteLine("\t\t\t" + b.add_state + b.Added_Behavior()); Console.ReadKey(); }
public Text_Color(New_Console console) { decorate_console = console; }
public Background_Color(New_Console console) { this.decorate_console = console; }