static void Main(string[] args)
        {
            Console.WriteLine("装饰模式:动态的给一个对象增加一些额外的职责,就增加对象功能来说,装饰模式比生成子类实现更为灵活。装饰模式是一种对象结构型模式。");

            Component c1, c2,C3;
            c1 = new ConcreteComponent1();
            c2 = new ConcreteDecorator1(c1);
            c2.display();
            C3 = new ConcreteDecorator2(c2);
            C3.display();

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("装饰模式:动态的给一个对象增加一些额外的职责,就增加对象功能来说,装饰模式比生成子类实现更为灵活。装饰模式是一种对象结构型模式。");

            Component c1, c2, C3;

            c1 = new ConcreteComponent1();
            c2 = new ConcreteDecorator1(c1);
            c2.display();
            C3 = new ConcreteDecorator2(c2);
            C3.display();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Component obj = new ConcreteComponent();

            obj.Operation();
            Decorator objDecorator = new ConcreteDecorator();

            objDecorator.SetComponent(obj);
            objDecorator.Operation();
            Decorator objDecorator2 = new ConcreteDecorator2();

            objDecorator2.SetComponent(objDecorator);
            objDecorator2.Operation();
        }