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