Esempio n. 1
0
        static void Main(string[] args)
        {
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.setComponent(c);
            d2.setComponent(d1);
            d2.Operation();
        }
Esempio n. 2
0
        static void sMain(string[] args)
        {
            var c = new ConcreteComponent();
            var a = new ConcreteDecoratorA();
            var b = new ConcreteDecoratorB();

            a.SetComponent(c);
            b.SetComponent(a);
            b.Operation();
        }
        private static void Main(string[] args)
        {
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();

            Console.Read();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("单独调用被装饰类");
            Component component = new ConcreteComponent();

            component.operation();

            Console.WriteLine("通过调用装饰类调用被装饰类");
            component = new ConcreteDecorator(component);
            component.operation();

            Console.Read();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            ConcreteComponent c = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();

            Console.Read();
        }