Beispiel #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.");
        }
Beispiel #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);
        }
Beispiel #3
0
 public DuckProxyExample(OtherDuck duck)
 {
     target = duck;
 }
Beispiel #4
0
 public DuckProxyExample(OtherDuck duck)
 {
     target = duck;
 }