示例#1
0
        public void SendRequest()
        {
            var realSubject = new RealSubject();

            PreSendRequest();
            realSubject.SendRequest();
            PostSendRequest();
        }
示例#2
0
        public void PerformAction()
        {
            if (_realSubject == null)
            {
                _realSubject = new RealSubject();
            }

            _realSubject.PerformAction();
        }
示例#3
0
 public override void Request()
 {
     // Use 'lazy initialization'
     if (_subject == null)
     {
         _subject = new RealSubject();
     }
     //do other things. Check security
     _subject.Request();
 }
        public override void Request()
        {
            // Use 'lazy initialization'
            if (_realSubject == null)
            {
                _realSubject = new RealSubject();
            }

            _realSubject.Request();
        }
        public override void Request()
        {
            // Use 'lazy initialization'
            if (_realSubject == null)
            {
                _realSubject = new RealSubject();
            }

            _realSubject.Request();
        }
示例#6
0
        static void Main(string[] args)
        {
            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);
        }
示例#7
0
 public Proxy(RealSubject realSubject)
 {
     _realSubject = realSubject;
 }
示例#8
0
 public Proxy(RealSubject realSubject)
 {
     this._realSubject = realSubject;
 }