} // ObjRef .ctor internal bool CanSmuggle() { // make sure this isn't a derived class or an ObjRefLite if ((this.GetType() != typeof(ObjRef)) || IsObjRefLite()) { return(false); } Type typeOfTypeInfo = typeInfo.GetType(); if (((typeOfTypeInfo == typeof(TypeInfo)) || (typeOfTypeInfo == typeof(DynamicTypeInfo))) && (envoyInfo == null) && (channelInfo.GetType() == typeof(ChannelInfo))) { foreach (Object channelData in channelInfo.ChannelData) { // Only consider CrossAppDomainData smuggleable. if (!(channelData is CrossAppDomainData)) { return(false); } } return(true); } else { return(false); } } // CanSmuggle
// Check whether we can cast the transparent proxy to the given type public bool CanCastTo(Type castType, Object o) { bool fCastOK = false; // The identity should be non-null BCLDebug.Assert(null != IdentityObject, "null != IdentityObject"); Message.DebugOut("CheckCast for identity " + IdentityObject.GetType()); if ((castType == s_typeofObject) || (castType == s_typeofMarshalByRefObject)) { return(true); } // Get the objref of the proxy ObjRef oRef = IdentityObject.ObjectRef; // If the object ref is non-null then check against the type info // stored in the it if (null != oRef) { Object oTP = GetTransparentProxy(); // Check that there is a matching type in the server object // hierarchy represented in the objref Message.DebugOut("Calling CanCastTo for type " + castType); IRemotingTypeInfo typeInfo = oRef.TypeInfo; if (null != typeInfo) { fCastOK = typeInfo.CanCastTo(castType, oTP); if (!fCastOK && typeInfo.GetType() == typeof(TypeInfo) && oRef.IsWellKnown()) { fCastOK = CanCastToWK(castType); } } else { if (oRef.IsObjRefLite()) { // we should do a dynamic cast across the network fCastOK = MarshalByRefObject.CanCastToXmlTypeHelper(castType, (MarshalByRefObject)o); } } } // This is a well known object which does not have a backing ObjRef else { fCastOK = CanCastToWK(castType); } return(fCastOK); }
public bool CanCastTo(Type castType, object o) { if (castType == (Type)null) { throw new ArgumentNullException("castType"); } RuntimeType castType1 = castType as RuntimeType; if (castType1 == (RuntimeType)null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } bool flag = false; if (castType1 == RemotingProxy.s_typeofObject || castType1 == RemotingProxy.s_typeofMarshalByRefObject) { return(true); } ObjRef objectRef = this.IdentityObject.ObjectRef; if (objectRef != null) { object transparentProxy = this.GetTransparentProxy(); IRemotingTypeInfo typeInfo = objectRef.TypeInfo; if (typeInfo != null) { flag = typeInfo.CanCastTo((Type)castType1, transparentProxy); if (!flag && typeInfo.GetType() == typeof(System.Runtime.Remoting.TypeInfo) && objectRef.IsWellKnown()) { flag = this.CanCastToWK((Type)castType1); } } else if (objectRef.IsObjRefLite()) { flag = MarshalByRefObject.CanCastToXmlTypeHelper(castType1, (MarshalByRefObject)o); } } else { flag = this.CanCastToWK((Type)castType1); } return(flag); }
public bool CanCastTo(Type castType, object o) { if (castType == null) { throw new ArgumentNullException("castType"); } RuntimeType fromType = castType as RuntimeType; if (fromType == null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } bool flag = false; if ((fromType == s_typeofObject) || (fromType == s_typeofMarshalByRefObject)) { return(true); } ObjRef objectRef = this.IdentityObject.ObjectRef; if (objectRef != null) { object transparentProxy = this.GetTransparentProxy(); IRemotingTypeInfo typeInfo = objectRef.TypeInfo; if (typeInfo != null) { flag = typeInfo.CanCastTo(fromType, transparentProxy); if ((!flag && (typeInfo.GetType() == typeof(TypeInfo))) && objectRef.IsWellKnown()) { flag = this.CanCastToWK(fromType); } return(flag); } if (objectRef.IsObjRefLite()) { flag = MarshalByRefObject.CanCastToXmlTypeHelper(fromType, (MarshalByRefObject)o); } return(flag); } return(this.CanCastToWK(fromType)); }