Operation() public méthode

public Operation ( ) : void
Résultat void
Exemple #1
0
        static void Main(string[] args)
        {
            Component myComponent = new ConcreteComponent();
            Console.WriteLine("CC: {0}", myComponent.Operation());

            myComponent = new ConcreteDecoratorA(myComponent);
            Console.WriteLine("CC + DCA: {0}", myComponent.Operation());

            myComponent = new ConcreteDecoratorB(myComponent);
            Console.WriteLine("CC + DCB: {0}", myComponent.Operation());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var compo      = new ConcreteComponent();
            var decorator1 = new ConcreteDecoratorA(compo);
            var decorator2 = new ConcreteDecoratorB(compo);
            var decorator3 = new ConcreteDecoratorA(new ConcreteDecoratorB(compo));

            compo.Operation();
            decorator1.Operation();
            decorator2.Operation();
            decorator3.Operation();
        }
        static void Main(string[] args)
        {
            var component = new ConcreteComponent();

            component.Operation();
            Console.WriteLine();

            var changedComponent = new DecoratedComponent(component, "new state");

            changedComponent.Operation();

            Console.ReadKey();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Component component = new ConcreteComponent("Start");

            Console.WriteLine(component.Operation());

            component = new ConcreteDecoratorA(component);
            Console.WriteLine(component.Operation());

            component = new ConcreteDecoratorB(component);
            Console.WriteLine(component.Operation());

            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Component obj = new ConcreteComponent();

            obj.Operation();
            Decorator objDecorator = new ConcreteDecorator();

            objDecorator.SetComponent(obj);
            objDecorator.Operation();
            Decorator objDecorator2 = new ConcreteDecorator2();

            objDecorator2.SetComponent(objDecorator);
            objDecorator2.Operation();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            ConcreteComponent concreteComponent = new ConcreteComponent();

            concreteComponent.Operation();

            ConcreteDecoratorA decoratorA = new ConcreteDecoratorA();

            decoratorA.SetComponent(concreteComponent);
            ConcreteDecoratorB decoratorB = new ConcreteDecoratorB();

            decoratorB.SetComponent(concreteComponent);

            decoratorA.Operation();
            decoratorB.Operation();


            Console.WriteLine("-----------------------------");

            Repo repo = new Repo();

            repo.GetId();

            DecoratorForIRepo decoratorForIRepo = new DecoratorForIRepo(repo);

            decoratorForIRepo.GetId();

            Console.WriteLine("-----------------------------");

            new CofeeHelper().ShouldSupportCondiments();


            Console.WriteLine("-----------------------------");


            BaseCar baseCar = new BaseCar();

            Console.WriteLine(baseCar.GetCarCharacteristic());
            Console.WriteLine(baseCar.GetCost());

            ICarSet superCar = new AutomaticTransmissionSet(baseCar);

            Console.WriteLine(superCar.GetCarCharacteristic());
            Console.WriteLine(superCar.GetCost());
        }
Exemple #7
0
        static void Main(string[] args)
        {
            ConcreteComponent cc = new ConcreteComponent();

            cc.Operation();
            Console.WriteLine();

            ConcreteDecoratorA cd1 = new ConcreteDecoratorA(cc);

            cd1.Operation();
            Console.WriteLine();

            ConcreteDecoratorB cd2 = new ConcreteDecoratorB(cc);

            cd2.Operation();
            Console.WriteLine();


            Console.ReadKey();
        }