GetTransparentProxy() public method

public GetTransparentProxy ( ) : Object
return Object
 public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
 {
     object transparentProxy = oldcp.GetTransparentProxy();
     object tp = newcp.GetTransparentProxy();
     RemotingServices.GetServerContextForProxy(transparentProxy);
     RemotingServices.GetServerContextForProxy(tp);
     Marshal.InternalSwitchCCW(transparentProxy, tp);
 }
        [System.Security.SecurityCritical]  // auto-generated_required
        public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
        {
            Object oldtp = oldcp.GetTransparentProxy(); 
            Object newtp = newcp.GetTransparentProxy();
 
            IntPtr oldcontextId = RemotingServices.GetServerContextForProxy(oldtp); 
            IntPtr newcontextId = RemotingServices.GetServerContextForProxy(newtp);
 
            // switch the CCW from oldtp to new tp
            Marshal.InternalSwitchCCW(oldtp, newtp);
        }
Esempio n. 3
0
        [System.Security.SecurityCritical]  // auto-generated 
        private static bool CheckCast(RealProxy rp, RuntimeType castType)
        { 
            // NOTE: This is the point where JIT_CheckCastClass ultimately 
            // lands up in the managed world if the object being cast is
            // a transparent proxy. 
            // If we are here, it means that walking the current EEClass
            // up the chain inside the EE was unable to verify the cast.

            Message.DebugOut("Entered CheckCast for type " + castType); 
            bool fCastOK = false;
 
            BCLDebug.Assert(rp != null, "Shouldn't be called with null real proxy."); 

            // Always return true if cast is to System.Object 
            if (castType == typeof(Object))
                return true;

            // We do not allow casting to non-interface types that do not extend 
            // from System.MarshalByRefObject
            if (!castType.IsInterface && !castType.IsMarshalByRef) 
                return false; 

            // Note: this is a bit of a hack to allow deserialization of WellKnown 
            // object refs (in the well known cases, we always return TRUE for
            // interface casts but doing so messes us up in the case when
            // the object manager is trying to resolve object references since
            // it ends up thinking that the proxy we returned needs to be resolved 
            // further).
            if (castType != typeof(IObjectReference)) 
            { 
                IRemotingTypeInfo typeInfo = rp as IRemotingTypeInfo;
                if(null != typeInfo) 
                {
                    fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
                }
                else 
                {
                    // The proxy does not implement IRemotingTypeInfo, so we should 
                    //   try to do casting based on the ObjRef type info. 
                    Identity id = rp.IdentityObject;
                    if (id != null) 
                    {
                        ObjRef objRef = id.ObjectRef;
                        if (objRef != null)
                        { 
                            typeInfo = objRef.TypeInfo;
                            if (typeInfo != null) 
                            { 
                                fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
                            } 
                        }
                    }
                }
            } 

            Message.DebugOut("CheckCast returning " + fCastOK); 
            return fCastOK; 
        }
 private static bool CheckCast(RealProxy rp, RuntimeType castType)
 {
     bool flag = false;
     if (castType == typeof(object))
     {
         return true;
     }
     if (!castType.IsInterface && !castType.IsMarshalByRef)
     {
         return false;
     }
     if (castType != typeof(IObjectReference))
     {
         IRemotingTypeInfo typeInfo = rp as IRemotingTypeInfo;
         if (typeInfo != null)
         {
             return typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
         }
         Identity identityObject = rp.IdentityObject;
         if (identityObject != null)
         {
             ObjRef objectRef = identityObject.ObjectRef;
             if (objectRef != null)
             {
                 typeInfo = objectRef.TypeInfo;
                 if (typeInfo != null)
                 {
                     flag = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
                 }
             }
         }
     }
     return flag;
 }