static void Main() { // Create ConcreteComponent and two Decorators ConcreteComponent c = new ConcreteComponent(); ConcreteDecoratorA d1 = new ConcreteDecoratorA(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); ChristmasTree ct = new ChristmasTree(); ToyChristmasTreeDecorator td = new ToyChristmasTreeDecorator(); GarlandChristmasTreeDecorator gd = new GarlandChristmasTreeDecorator(); td.SetTree(ct); gd.SetTree(ct); td.DecotateChristmasTree(); gd.DecotateChristmasTree(); // Link decorators d1.SetComponent(c); d2.SetComponent(d1); d2.Operation(); // Wait for user Console.Read(); }
static void Main() { // Create ConcreteComponent and two Decorators ConcreteComponent c = new ConcreteComponent(); ConcreteDecoratorA d1 = new ConcreteDecoratorA(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); // Link decorators d1.SetComponent(c); d2.SetComponent(d1); d2.Operation(); // Wait for user Console.Read(); }