public override void Request(string Value) { if (_realSubject == null) { _realSubject = new RealSubject(); } _realSubject.Request(Value); }
// Constructor public Proxy() { var ad = AppDomain.CreateDomain("RealSubjectDomain", null, null); var o = ad.CreateInstance( this.GetType().Namespace, this.GetType().Namespace + ".RealSubject"); realSubject = (RealSubject)o.Unwrap(); }
// The most common applications of the Proxy pattern are lazy loading, // caching, controlling the access, logging, etc. A Proxy can perform // one 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 (this.CheckAccess()) { this._realSubject = new RealSubject(); this._realSubject.Request(); this.LogAccess(); } }
public Client() { Program program = new Program(); Console.WriteLine("Program: Executing the client code with a real subject:"); RealSubject realSubject = new RealSubject(); program.ProgramCode(realSubject); Console.WriteLine(); Console.WriteLine("Program: Executing the same client code with a proxy:"); Proxy proxy = new Proxy(realSubject); program.ProgramCode(proxy); }
public void Ex1() { Client client = new Client(); Console.WriteLine("Client: Executing the client code with a real subject:"); RealSubject realSubject = new RealSubject(); client.ClientCode(realSubject); Console.WriteLine(); Console.WriteLine("Client: Executing the same client code with a proxy:"); Proxy proxy = new Proxy(realSubject); client.ClientCode(proxy); }
public Proxy(RealSubject realSubject) { _realSubject = realSubject; }
public Proxy(RealSubject realSubject) { this._realSubject = realSubject; }