Exemple #1
0
        static void Main(string[] args)
        {
            //test();

            Console.WriteLine("");
            Console.WriteLine("CustomProxy Sample");
            Console.WriteLine("================");
            Console.WriteLine("");
            // Create an instance of MyProxy.
            DynamicProxy myProxyInstance = new DynamicProxy(typeof(Cicada));
            // Get a CustomServer proxy.
            IAnimal myHelloServer = (Cicada)myProxyInstance.GetTransparentProxy();

            // Get stubdata.
            Console.WriteLine("GetStubData = " + RealProxy.GetStubData(myProxyInstance).ToString());
            // Get ProxyType.
            Console.WriteLine("Type of object represented by RealProxy is :"
                              + myProxyInstance.GetProxiedType());
            //myHelloServer.HelloMethod("RealProxy Sample");
            myHelloServer.Eating();
            //Console.WriteLine("");
            // Get a reference object from server.
            //Console.WriteLine("Create an objRef object to be marshalled across Application Domains...");
            //ObjRef CustomObjRef = myProxyInstance.CreateObjRef(typeof(CustomServer));
            //Console.WriteLine("URI of 'ObjRef' object =  " + CustomObjRef.URI);
        }