GetReflectionCachedData() static private method

static private GetReflectionCachedData ( MemberInfo mi ) : RemotingCachedData
mi MemberInfo
return RemotingCachedData
Esempio n. 1
0
        internal static RemotingCachedData GetReflectionCachedData(MemberInfo mi)
        {
            MethodBase mi1;

            if ((mi1 = mi as MethodBase) != (MethodBase)null)
            {
                return((RemotingCachedData)InternalRemotingServices.GetReflectionCachedData(mi1));
            }
            RuntimeType type;

            if ((type = mi as RuntimeType) != (RuntimeType)null)
            {
                return((RemotingCachedData)InternalRemotingServices.GetReflectionCachedData(type));
            }
            RuntimeFieldInfo runtimeFieldInfo;

            if ((FieldInfo)(runtimeFieldInfo = mi as RuntimeFieldInfo) != (FieldInfo)null)
            {
                return((RemotingCachedData)runtimeFieldInfo.RemotingCache);
            }
            SerializationFieldInfo serializationFieldInfo;

            if ((FieldInfo)(serializationFieldInfo = mi as SerializationFieldInfo) != (FieldInfo)null)
            {
                return((RemotingCachedData)serializationFieldInfo.RemotingCache);
            }
            throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject"));
        }
        internal static bool IsActivationAllowed(RuntimeType svrType)
        {
            if (svrType == null)
            {
                return(false);
            }
            string simpleAssemblyName = InternalRemotingServices.GetReflectionCachedData(svrType).SimpleAssemblyName;

            return(Info.ActivationAllowed(svrType.FullName, simpleAssemblyName));
        }
        internal static WellKnownClientTypeEntry IsWellKnownClientType(RuntimeType svrType)
        {
            string simpleAssemblyName      = InternalRemotingServices.GetReflectionCachedData(svrType).SimpleAssemblyName;
            WellKnownClientTypeEntry entry = Info.QueryConnect(svrType.FullName, simpleAssemblyName);

            if (entry == null)
            {
                entry = Info.QueryConnect(svrType.Name, simpleAssemblyName);
            }
            return(entry);
        }
Esempio n. 4
0
        public static SoapAttribute GetCachedSoapAttribute(object reflectionObject)
        {
            MemberInfo           mi = reflectionObject as MemberInfo;
            RuntimeParameterInfo reflectionObject1 = reflectionObject as RuntimeParameterInfo;

            if (mi != (MemberInfo)null)
            {
                return(InternalRemotingServices.GetReflectionCachedData(mi).GetSoapAttribute());
            }
            if (reflectionObject1 != null)
            {
                return(InternalRemotingServices.GetReflectionCachedData(reflectionObject1).GetSoapAttribute());
            }
            return((SoapAttribute)null);
        }
        internal static ActivatedClientTypeEntry IsRemotelyActivatedClientType(RuntimeType svrType)
        {
            RemotingTypeCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(svrType);
            string simpleAssemblyName      = reflectionCachedData.SimpleAssemblyName;
            ActivatedClientTypeEntry entry = Info.QueryRemoteActivate(svrType.FullName, simpleAssemblyName);

            if (entry == null)
            {
                string assemblyName = reflectionCachedData.AssemblyName;
                entry = Info.QueryRemoteActivate(svrType.FullName, assemblyName);
                if (entry == null)
                {
                    entry = Info.QueryRemoteActivate(svrType.Name, simpleAssemblyName);
                }
            }
            return(entry);
        }
Esempio n. 6
0
        //
        //
        internal void Init(Object o, Identity idObj, Type requestedType)
        {
            Message.DebugOut("RemotingServices::FillObjRef: IN");
            BCLDebug.Assert(idObj != null, "idObj != null");

            // Set the URI of the object to be marshaled
            uri = idObj.URI;

            // Figure out the type
            MarshalByRefObject obj = idObj.TPOrObject;

            BCLDebug.Assert(null != obj, "Identity not setup correctly");

            // Get the type of the object
            Type serverType = null;

            if (!RemotingServices.IsTransparentProxy(obj))
            {
                serverType = obj.GetType();
            }
            else
            {
                serverType = RemotingServices.GetRealProxy(obj).GetProxiedType();
            }

            Type typeOfObj = (null == requestedType ? serverType : requestedType);

            // Make sure that the server and requested types are compatible
            //  (except for objects that implement IMessageSink, since we
            //   just hand off the message instead of invoking the proxy)
            if ((null != requestedType) &&
                !requestedType.IsAssignableFrom(serverType) &&
                (!typeof(IMessageSink).IsAssignableFrom(serverType)))
            {
                throw new RemotingException(
                          String.Format(
                              CultureInfo.CurrentCulture, Environment.GetResourceString(
                                  "Remoting_InvalidRequestedType"),
                              requestedType.ToString()));;
            }

            {
                RemotingTypeCachedData cache = (RemotingTypeCachedData)
                                               InternalRemotingServices.GetReflectionCachedData(typeOfObj);

                TypeInfo = (IRemotingTypeInfo)cache.TypeInfo;
            }

            if (!idObj.IsWellKnown())
            {
                // Create the envoy info
                EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity);

                // Create the channel info
                IChannelInfo chan = (IChannelInfo) new ChannelInfo();
                // Make sure the channelInfo only has x-appdomain data since the objref is agile while other
                // channelData might not be and regardless this data is useless for an appdomain proxy
                if (o is AppDomain)
                {
                    Object[] channelData       = chan.ChannelData;
                    int      channelDataLength = channelData.Length;
                    Object[] newChannelData    = new Object[channelDataLength];
                    Array.Copy(channelData, newChannelData, channelDataLength);
                    for (int i = 0; i < channelDataLength; i++)
                    {
                        if (!(newChannelData[i] is CrossAppDomainData))
                        {
                            newChannelData[i] = null;
                        }
                    }
                    chan.ChannelData = newChannelData;
                }
                ChannelInfo = chan;

                if (serverType.HasProxyAttribute)
                {
                    SetHasProxyAttribute();
                }
            }
            else
            {
                SetWellKnown();
            }

            // See if we should and can use a url obj ref?
            if (ShouldUseUrlObjRef())
            {
                if (IsWellKnown())
                {
                    // full uri already supplied.
                    SetObjRefLite();
                }
                else
                {
                    String httpUri = ChannelServices.FindFirstHttpUrlForObject(URI);
                    if (httpUri != null)
                    {
                        URI = httpUri;
                        SetObjRefLite();
                    }
                }
            }
        } // Init
        internal void Init(object o, Identity idObj, RuntimeType requestedType)
        {
            this.uri = idObj.URI;
            MarshalByRefObject tporObject = idObj.TPOrObject;
            RuntimeType        runtimeType;

            if (!RemotingServices.IsTransparentProxy(tporObject))
            {
                runtimeType = (RuntimeType)tporObject.GetType();
            }
            else
            {
                runtimeType = (RuntimeType)RemotingServices.GetRealProxy(tporObject).GetProxiedType();
            }
            RuntimeType runtimeType2 = (null == requestedType) ? runtimeType : requestedType;

            if (null != requestedType && !requestedType.IsAssignableFrom(runtimeType) && !typeof(IMessageSink).IsAssignableFrom(runtimeType))
            {
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_InvalidRequestedType"), requestedType.ToString()));
            }
            if (runtimeType.IsCOMObject)
            {
                DynamicTypeInfo dynamicTypeInfo = new DynamicTypeInfo(runtimeType2);
                this.TypeInfo = dynamicTypeInfo;
            }
            else
            {
                RemotingTypeCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(runtimeType2);
                this.TypeInfo = reflectionCachedData.TypeInfo;
            }
            if (!idObj.IsWellKnown())
            {
                this.EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity);
                IChannelInfo channelInfo = new ChannelInfo();
                if (o is AppDomain)
                {
                    object[] channelData = channelInfo.ChannelData;
                    int      num         = channelData.Length;
                    object[] array       = new object[num];
                    Array.Copy(channelData, array, num);
                    for (int i = 0; i < num; i++)
                    {
                        if (!(array[i] is CrossAppDomainData))
                        {
                            array[i] = null;
                        }
                    }
                    channelInfo.ChannelData = array;
                }
                this.ChannelInfo = channelInfo;
                if (runtimeType.HasProxyAttribute)
                {
                    this.SetHasProxyAttribute();
                }
            }
            else
            {
                this.SetWellKnown();
            }
            if (ObjRef.ShouldUseUrlObjRef())
            {
                if (this.IsWellKnown())
                {
                    this.SetObjRefLite();
                    return;
                }
                string text = ChannelServices.FindFirstHttpUrlForObject(this.URI);
                if (text != null)
                {
                    this.URI = text;
                    this.SetObjRefLite();
                }
            }
        }
Esempio n. 8
0
        internal void Init(object o, Identity idObj, RuntimeType requestedType)
        {
            this.uri = idObj.URI;
            MarshalByRefObject tpOrObject   = idObj.TPOrObject;
            RuntimeType        runtimeType1 = RemotingServices.IsTransparentProxy((object)tpOrObject) ? (RuntimeType)RemotingServices.GetRealProxy((object)tpOrObject).GetProxiedType() : (RuntimeType)tpOrObject.GetType();
            RuntimeType        runtimeType2 = (RuntimeType)null == requestedType ? runtimeType1 : requestedType;

            if ((RuntimeType)null != requestedType && !requestedType.IsAssignableFrom((System.Reflection.TypeInfo)runtimeType1) && !typeof(IMessageSink).IsAssignableFrom((Type)runtimeType1))
            {
                throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_InvalidRequestedType"), (object)requestedType.ToString()));
            }
            this.TypeInfo = !runtimeType1.IsCOMObject ? (IRemotingTypeInfo)InternalRemotingServices.GetReflectionCachedData(runtimeType2).TypeInfo : (IRemotingTypeInfo) new DynamicTypeInfo(runtimeType2);
            if (!idObj.IsWellKnown())
            {
                this.EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity);
                IChannelInfo channelInfo = (IChannelInfo) new System.Runtime.Remoting.ChannelInfo();
                if (o is AppDomain)
                {
                    object[] channelData = channelInfo.ChannelData;
                    int      length1     = channelData.Length;
                    object[] objArray1   = new object[length1];
                    object[] objArray2   = objArray1;
                    int      length2     = length1;
                    Array.Copy((Array)channelData, (Array)objArray2, length2);
                    for (int index = 0; index < length1; ++index)
                    {
                        if (!(objArray1[index] is CrossAppDomainData))
                        {
                            objArray1[index] = (object)null;
                        }
                    }
                    channelInfo.ChannelData = objArray1;
                }
                this.ChannelInfo = channelInfo;
                if (runtimeType1.HasProxyAttribute)
                {
                    this.SetHasProxyAttribute();
                }
            }
            else
            {
                this.SetWellKnown();
            }
            if (!ObjRef.ShouldUseUrlObjRef())
            {
                return;
            }
            if (this.IsWellKnown())
            {
                this.SetObjRefLite();
            }
            else
            {
                string httpUrlForObject = ChannelServices.FindFirstHttpUrlForObject(this.URI);
                if (httpUrlForObject == null)
                {
                    return;
                }
                this.URI = httpUrlForObject;
                this.SetObjRefLite();
            }
        }
Esempio n. 9
0
        //
        //
        internal void Init(Identity idObj, Type requestedType)
        {
            Message.DebugOut("RemotingServices::FillObjRef: IN");
            BCLDebug.Assert(idObj != null, "idObj != null");

            // Set the URI of the object to be marshaled
            URI = idObj.URI;

            // Figure out the type
            MarshalByRefObject obj = idObj.TPOrObject;

            BCLDebug.Assert(null != obj, "Identity not setup correctly");

            // Get the type of the object
            Type serverType = null;

            if (!RemotingServices.IsTransparentProxy(obj))
            {
                serverType = obj.GetType();
            }
            else
            {
                serverType = RemotingServices.GetRealProxy(obj).GetProxiedType();
            }

            Type typeOfObj = (null == requestedType ? serverType : requestedType);

            // Make sure that the server and requested types are compatible
            //  (except for objects that implement IMessageSink, since we
            //   just hand off the message instead of invoking the proxy)
            if ((null != requestedType) &&
                !requestedType.IsAssignableFrom(serverType) &&
                (!typeof(IMessageSink).IsAssignableFrom(serverType)))
            {
                throw new RemotingException(
                          String.Format(
                              Environment.GetResourceString(
                                  "Remoting_InvalidRequestedType"),
                              requestedType.ToString()));;
            }

            // Create the type info
            if (serverType.IsCOMObject)
            {
                // __ComObjects need dynamic TypeInfo
                DynamicTypeInfo dt = new DynamicTypeInfo(typeOfObj);
                TypeInfo = (IRemotingTypeInfo)dt;
            }
            else
            {
                RemotingTypeCachedData cache = (RemotingTypeCachedData)
                                               InternalRemotingServices.GetReflectionCachedData(typeOfObj);

                TypeInfo = (IRemotingTypeInfo)cache.TypeInfo;
            }

            if (!idObj.IsWellKnown())
            {
                // Create the envoy info
                EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity);

                // Create the channel info
                ChannelInfo = (IChannelInfo) new ChannelInfo();

                if (serverType.HasProxyAttribute)
                {
                    SetHasProxyAttribute();
                }
            }
            else
            {
                SetWellKnown();
            }

            // See if we should and can use a url obj ref?
            if (ShouldUseUrlObjRef())
            {
                if (IsWellKnown())
                {
                    // full uri already supplied.
                    SetObjRefLite();
                }
                else
                {
                    String httpUri = ChannelServices.FindFirstHttpUrlForObject(URI);
                    if (httpUri != null)
                    {
                        URI = httpUri;
                        SetObjRefLite();
                    }
                }
            }
        } // Init
Esempio n. 10
0
        internal void Init(object o, Identity idObj, RuntimeType requestedType)
        {
            this.uri = idObj.URI;
            MarshalByRefObject tPOrObject = idObj.TPOrObject;
            RuntimeType        c          = null;

            if (!RemotingServices.IsTransparentProxy(tPOrObject))
            {
                c = (RuntimeType)tPOrObject.GetType();
            }
            else
            {
                c = (RuntimeType)RemotingServices.GetRealProxy(tPOrObject).GetProxiedType();
            }
            RuntimeType typeOfObj = (null == requestedType) ? c : requestedType;

            if (((null != requestedType) && !requestedType.IsAssignableFrom(c)) && !typeof(IMessageSink).IsAssignableFrom(c))
            {
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_InvalidRequestedType"), new object[] { requestedType.ToString() }));
            }
            if (c.IsCOMObject)
            {
                DynamicTypeInfo info = new DynamicTypeInfo(typeOfObj);
                this.TypeInfo = info;
            }
            else
            {
                RemotingTypeCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(typeOfObj);
                this.TypeInfo = reflectionCachedData.TypeInfo;
            }
            if (!idObj.IsWellKnown())
            {
                this.EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity);
                IChannelInfo info2 = new System.Runtime.Remoting.ChannelInfo();
                if (o is AppDomain)
                {
                    object[] channelData      = info2.ChannelData;
                    int      length           = channelData.Length;
                    object[] destinationArray = new object[length];
                    Array.Copy(channelData, destinationArray, length);
                    for (int i = 0; i < length; i++)
                    {
                        if (!(destinationArray[i] is CrossAppDomainData))
                        {
                            destinationArray[i] = null;
                        }
                    }
                    info2.ChannelData = destinationArray;
                }
                this.ChannelInfo = info2;
                if (c.HasProxyAttribute)
                {
                    this.SetHasProxyAttribute();
                }
            }
            else
            {
                this.SetWellKnown();
            }
            if (ShouldUseUrlObjRef())
            {
                if (this.IsWellKnown())
                {
                    this.SetObjRefLite();
                }
                else
                {
                    string str = ChannelServices.FindFirstHttpUrlForObject(this.URI);
                    if (str != null)
                    {
                        this.URI = str;
                        this.SetObjRefLite();
                    }
                }
            }
        }