예제 #1
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public void Execute()
        {
            // Create ConcreteComponent and two Decorators
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            // Link decorators
            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();
        }
예제 #2
0
        public void Run()
        {
            // Create ConcreteComponent and two Decorators
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.Component = c;
            d2.Component = d1;
            d2.Operation();

            // Wait for user
            Console.ReadKey();
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            // Create ConcreteComponent and two Decorators
              ConcreteComponent c = new ConcreteComponent();
              ConcreteDecoratorA d1 = new ConcreteDecoratorA();
              ConcreteDecoratorB d2 = new ConcreteDecoratorB();

              // Link decorators
              d1.SetComponent(c);
              d2.SetComponent(d1);

              d2.Operation();

              // Wait for user
              Console.ReadKey();
        }
예제 #4
0
        public void Test()
        {
            var component = new ConcreteComponent();

            var decoratorA = new ConcreteDecoratorA {
                Component = component
            };

            decoratorA.Operation();

            var decoratorB = new ConcreteDecoratorB {
                Component = component
            };

            decoratorB.Operation();
        }
예제 #5
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            // Create ConcreteComponent and two Decorators
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            // Link decorators
            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();

            // Wait for user
            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Client client = new Client();

            var simple = new ConcreteComponent();

            Console.WriteLine("Client: I get a simple component:");
            client.ClientCode(simple);
            Console.WriteLine();

            // ...as well as decorated ones.
            //
            // Note how decorators can wrap not only simple components but the
            // other decorators as well.
            ConcreteDecoratorA decorator1 = new ConcreteDecoratorA(simple);
            ConcreteDecoratorB decorator2 = new ConcreteDecoratorB(decorator1);

            Console.WriteLine("Client: Now I've got a decorated component:");
            client.ClientCode(decorator2);
        }