public override void Request() { if (realsubject == null) { realsubject = new RealSubject(); } realsubject.Request(); }
public override string Request() { if (realSubject == null) { realSubject = new RealSubject(); } return(realSubject.Request()); }
public override void Request() { if (_realSubject == null) { _realSubject = new RealSubject(); } _realSubject.Request(); }
public void Request() { if (RealSubject == null) { RealSubject = new RealSubject(this.Data); // Here you could get the data from the database, for example. } RealSubject.Request(); }
//The most common applications of the Proxy pattern are lazy loading, caching, controlling the access, logging, etc. //A Proxy can perform on of these things and then, depending on the result, pass the execution to the same method //in a linked RealSubject object. public void Request() { if (CheckAccess()) { _realSubject.Request(); LogAccess(); } }
public override void Request() { //use lazy initialization if (_realSubject == null) { _realSubject = new RealSubject(); } _realSubject.Request(); }
static void Main(string[] args) { // canonical var subject = new RealSubject(); subject.Request(); var proxy = new Proxy.Canonical.Proxy(); proxy.Request(); // live Console.WriteLine(); var image = new ProxyImage("C://temp.jpq"); // will be loaded lazyly image.Display(); // wont be loaded 2nd time image.Display(); }
public override void Request() { //实例一个真实用户 realSubject = new RealSubject(); realSubject.Request();//调用真实用户的方法 }