示例#1
0
        static void Main(string[] args)
        {
            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.ReadKey();
        }
示例#2
0
        private static void Main()
        {
            Console.WriteLine("***Decorator pattern***\n");
            ConcreteComponent cc = new ConcreteComponent();

            ConcreteDecoratorEx1 dc1 = new ConcreteDecoratorEx1();

            dc1.SetTheComponent(cc);
            dc1.MakeHouse();

            ConcreteDecoratorEx2 dc2 = new ConcreteDecoratorEx2();

            dc2.SetTheComponent(dc1);
            dc2.MakeHouse();

            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Decorator pattern Demo***\n");
            ConcreteComponent cc = new ConcreteComponent();

            ConcreteDecoratorEx1 decoratorEx1 = new ConcreteDecoratorEx1();

            decoratorEx1.SetTheComponent(cc);
            decoratorEx1.makeHouse();

            ConcreteDecoratorEx2 decoratorEx2 = new ConcreteDecoratorEx2();

            decoratorEx2.SetTheComponent(decoratorEx1);
            decoratorEx2.makeHouse();

            Console.ReadKey();
        }