public override void Request(string Value)
 {
     if (_realSubject == null)
     {
         _realSubject = new RealSubject();
     }
     _realSubject.Request(Value);
 }
Exemple #2
0
        // 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();
        }
Exemple #3
0
        // 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();
            }
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public Proxy(RealSubject realSubject)
 {
     _realSubject = realSubject;
 }
Exemple #7
0
 public Proxy(RealSubject realSubject)
 {
     this._realSubject = realSubject;
 }