예제 #1
0
        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();
        }
예제 #2
0
파일: Program.cs 프로젝트: ksush23/Patterns
        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();
        }