diff --git a/Design Pattern Examples/Proxy/Program.cs b/Design Pattern Examples/Proxy/Program.cs new file mode 100644 index 0000000..958b739 --- /dev/null +++ b/Design Pattern Examples/Proxy/Program.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace proxyexample +{ + public interface IClient + { + string GetData(); + } + + public class RealClient : IClient + { + string Data; + public RealClient() + { + Console.WriteLine("Real Client: initilizalized"); + Data = "realclient test"; + } + + public string GetData() + { + return Data; + } + } + + public class ProxyClient : IClient + { + RealClient client = new RealClient(); + + public ProxyClient() + { + Console.WriteLine("ProxyClient: Intilizied"); + } + + public string GetData() + { + return "X-Header1: test\n" + client.GetData(); + } + } + + class Program + { + static void Main(string[] args) + { + ProxyClient proxy = new ProxyClient(); + Console.WriteLine("Data from proxy client = {0}", proxy.GetData()); + } + } +}