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(); } } }
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(); } }