public string Request() { // A virtual proxy creates the object only on its first method call if(_subject==null) { Console.WriteLine("Subject inactive"); _subject = new Subject(); } Console.WriteLine("Subject active"); return "Proxy: Call to " + _subject.Request(); }
public string Authenticate(string supplied) { if(supplied!=_password) { return "Protection Proxy: No Access"; } else { _subject = new Subject(); return "Protection Proxy: Authenticated"; } }