Ejemplo n.º 1
0
    //
    void UnitTest()
    {
        // 物件
        ConcreteComponent theComponent = new ConcreteComponent();

        // 增加Decorator
        ConcreteDecoratorA theDecoratorA = new ConcreteDecoratorA(theComponent);

        theDecoratorA.Operator();

        ConcreteDecoratorB theDecoratorB = new ConcreteDecoratorB(theComponent);

        theDecoratorB.Operator();

        // 再增加一層
        ConcreteDecoratorB theDecoratorB2 = new ConcreteDecoratorB(theDecoratorA);

        theDecoratorB2.Operator();
    }