예제 #1
0
        public void Test_Proxy()
        {
            int      result    = 0;
            ISubject mySubject = new MySubject();

            result = mySubject.Request("param1");
            Assert.AreEqual(1, result);

            ISubject myProxy = new MyProxy(mySubject);

            // adds 1000 for each proxy call

            result = myProxy.Request("param2");
            Assert.AreEqual(1001, result);

            result = myProxy.Request("param3");
            Assert.AreEqual(2001, result);

            result = myProxy.Request("");
            Assert.AreEqual(3001, result);
        }
예제 #2
0
        /// <summary>
        /// 代理模式
        /// </summary>
        static void TestProxy()
        {
            MyProxy myProxy = new MyProxy();

            myProxy.Request();
        }
예제 #3
0
    void Start()
    {
        MyProxy myProxy = new MyProxy();

        myProxy.Request();
    }