static void Main(string[] args) { Console.WriteLine("Client: Executing the client code with a real Internet:"); IInternet internet = new RealInternet(); try { internet.ConnectTo("craftcode.com"); internet.ConnectTo("abc.com"); } catch (Exception e) { Console.WriteLine(e.Message); } internet = new ProxyInternet(new RealInternet()); try { internet.ConnectTo("craftcode.com"); internet.ConnectTo("abc.com"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void ConnectTo(string serverHost) { List <string> webs = new List <string> { "abc.com", "dfr.com", "ert.com" }; if (webs.Contains(serverHost)) { throw new Exception("Access denied to: " + serverHost); } _realInternet.ConnectTo(serverHost); }