/// <summary> /// 代理或转发请求 /// </summary> public void Request() { PreRequest(); if (realSubject == null) realSubject = new RealSubject(); realSubject.Request();//代理转发 PostRequest(); }
public static void Test() { Console.WriteLine("==============================Proxy Test=================================="); //使用代理 Subject proxySubject = new ProxySubject(); proxySubject.Request(); //不使用代理 Subject realSubject = new RealSubject(); realSubject.Request(); }