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