Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
            Client client = new Client();

            Debug.Log("Client: Executing the client code with a real subject:");
            RealSubject realSubject = new RealSubject();

            client.ClientCode(realSubject);

            Debug.Log("--------");

            Debug.Log("Client: Executing the same client code with a proxy:");
            Proxy proxy = new Proxy(realSubject);

            client.ClientCode(proxy);
        }
Ejemplo n.º 3
0
 public Proxy(RealSubject realSubject)
 {
     this._realSubject = realSubject;
 }