static void Main(string[] args) { Subject subject = new RealSubject(); ProxySubject proxySubject = new ProxySubject(); proxySubject.subject = subject; proxySubject.visit(); Console.ReadLine(); }
static void Main(string[] args) { //初始化一个委托者 RealSubject real = new RealSubject(); //初始化一个代理者 Proxy proxy = new Proxy(); //委托者和代理者建立关系 proxy.Subject = real; //代理者去完成某事 proxy.Request(); Console.Read(); }