Exemplo n.º 1
0
        public void TestMethod1()
        {
            var component = new ConcreteComponent();
            var decoratorA = new ConcreateDecoratorA();
            var decoratorB = new ConcreateDecoratorB();
            decoratorA.SetComponent(component);
            decoratorB.SetComponent(decoratorA);

            decoratorB.Operation();
        }
Exemplo n.º 2
0
        public static void UseDecorator()
        {
            Console.WriteLine("***Decorator Pattern Demo***\n");

            ConcreteComponent cc = new ConcreteComponent();

            ConcreteDecoratorEx1 decorator1 = new ConcreteDecoratorEx1();

            decorator1.SetTheComponent(cc);
            //decorator1.MakeHouse();

            ConcreteDecoratorEx2 decorator2 = new ConcreteDecoratorEx2();

            //Adding results from decorator1
            decorator2.SetTheComponent(decorator1);
            decorator2.MakeHouse();


            Console.ReadLine();
        }