Exemplo n.º 1
0
        /// <summary>
        /// 增加需求后的修改代码.
        /// </summary>
        private static void Test2()
        {
            //全部使用抽象构件定义
            ComponentUI component, componentSB, componentBB;

            // 定义具体构件
            component = new Window();
            // 定义装饰后的构件
            componentSB = new ScrollBarDecorator(component);
            //将装饰了一次之后的对象继续注入到另一个装饰类中,进行第二次装饰
            componentBB = new BlackBorderDecorator(componentSB);

            // 显示.
            componentBB.Display();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Component component = new Window();

            Component componentSB = new ScrollBarDecorator(component);

            componentSB.Display();

            Console.WriteLine();

            Component componentBB = new BlackBorderDecorator(componentSB);

            componentBB.Display();

            Console.ReadKey();
        }