Exemplo n.º 1
0
        public void Run()
        {
            OtherDuck duck = new OtherDuck();
            DuckTypingProxyFactory factory = new DuckTypingProxyFactory();
            IMyDuck proxy = factory.GenerateProxy<IMyDuck>(duck);
            //IMyDuck proxy = new DuckProxyExample(duck);

            //Calling proxy
            proxy.Name = "Oregon";
            Console.WriteLine($"Duck name is {proxy.Name}.");
            proxy.Quack(3);
            double yards = proxy.Walk();
            Console.WriteLine($"Duck walked {yards} yards.");
        }
Exemplo n.º 2
0
        public void Run()
        {
            OtherDuck duck = new OtherDuck();
            DuckTypingProxyFactory factory = new DuckTypingProxyFactory();
            IMyDuck proxy = factory.GenerateProxy <IMyDuck>(duck);

            //IMyDuck proxy = new DuckProxyExample(duck);

            //Calling proxy
            proxy.Name = "Oregon";
            Console.WriteLine("Duck name is {0}.", proxy.Name);
            proxy.Quack(3);
            double yards = proxy.Walk();

            Console.WriteLine("Duck walked {0} yards.", yards);
        }
Exemplo n.º 3
0
 public DuckProxyExample(OtherDuck duck)
 {
     target = duck;
 }
Exemplo n.º 4
0
 public DuckProxyExample(OtherDuck duck)
 {
     target = duck;
 }