예제 #1
0
        private IChannelInfo GetChannelInfoHelper()
        {
            System.Runtime.Remoting.ChannelInfo channelInfo1 = this.channelInfo as System.Runtime.Remoting.ChannelInfo;
            if (channelInfo1 == null)
            {
                return(this.channelInfo);
            }
            object[] channelData = channelInfo1.ChannelData;
            if (channelData == null)
            {
                return((IChannelInfo)channelInfo1);
            }
            string[] strArray = (string[])CallContext.GetData("__bashChannelUrl");
            if (strArray == null)
            {
                return((IChannelInfo)channelInfo1);
            }
            string str1 = strArray[0];
            string str2 = strArray[1];

            System.Runtime.Remoting.ChannelInfo channelInfo2 = new System.Runtime.Remoting.ChannelInfo();
            channelInfo2.ChannelData = new object[channelData.Length];
            for (int index = 0; index < channelData.Length; ++index)
            {
                channelInfo2.ChannelData[index] = channelData[index];
                ChannelDataStore channelDataStore1 = channelInfo2.ChannelData[index] as ChannelDataStore;
                if (channelDataStore1 != null)
                {
                    string[] channelUris = channelDataStore1.ChannelUris;
                    if (channelUris != null && channelUris.Length == 1 && channelUris[0].Equals(str1))
                    {
                        ChannelDataStore channelDataStore2 = channelDataStore1.InternalShallowCopy();
                        channelDataStore2.ChannelUris    = new string[1];
                        channelDataStore2.ChannelUris[0] = str2;
                        channelInfo2.ChannelData[index]  = (object)channelDataStore2;
                    }
                }
            }
            return((IChannelInfo)channelInfo2);
        }
예제 #2
0
        private IChannelInfo GetChannelInfoHelper()
        {
            System.Runtime.Remoting.ChannelInfo channelInfo = this.channelInfo as System.Runtime.Remoting.ChannelInfo;
            if (channelInfo == null)
            {
                return(this.channelInfo);
            }
            object[] channelData = channelInfo.ChannelData;
            if (channelData == null)
            {
                return(channelInfo);
            }
            string[] data = (string[])CallContext.GetData("__bashChannelUrl");
            if (data == null)
            {
                return(channelInfo);
            }
            string str  = data[0];
            string str2 = data[1];

            System.Runtime.Remoting.ChannelInfo info2 = new System.Runtime.Remoting.ChannelInfo {
                ChannelData = new object[channelData.Length]
            };
            for (int i = 0; i < channelData.Length; i++)
            {
                info2.ChannelData[i] = channelData[i];
                ChannelDataStore store = info2.ChannelData[i] as ChannelDataStore;
                if (store != null)
                {
                    string[] channelUris = store.ChannelUris;
                    if (((channelUris != null) && (channelUris.Length == 1)) && channelUris[0].Equals(str))
                    {
                        ChannelDataStore store2 = store.InternalShallowCopy();
                        store2.ChannelUris   = new string[] { str2 };
                        info2.ChannelData[i] = store2;
                    }
                }
            }
            return(info2);
        }
 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();
             }
         }
     }
 }
 private IChannelInfo GetChannelInfoHelper()
 {
     System.Runtime.Remoting.ChannelInfo channelInfo = this.channelInfo as System.Runtime.Remoting.ChannelInfo;
     if (channelInfo == null)
     {
         return this.channelInfo;
     }
     object[] channelData = channelInfo.ChannelData;
     if (channelData == null)
     {
         return channelInfo;
     }
     string[] data = (string[]) CallContext.GetData("__bashChannelUrl");
     if (data == null)
     {
         return channelInfo;
     }
     string str = data[0];
     string str2 = data[1];
     System.Runtime.Remoting.ChannelInfo info2 = new System.Runtime.Remoting.ChannelInfo {
         ChannelData = new object[channelData.Length]
     };
     for (int i = 0; i < channelData.Length; i++)
     {
         info2.ChannelData[i] = channelData[i];
         ChannelDataStore store = info2.ChannelData[i] as ChannelDataStore;
         if (store != null)
         {
             string[] channelUris = store.ChannelUris;
             if (((channelUris != null) && (channelUris.Length == 1)) && channelUris[0].Equals(str))
             {
                 ChannelDataStore store2 = store.InternalShallowCopy();
                 store2.ChannelUris = new string[] { str2 };
                 info2.ChannelData[i] = store2;
             }
         }
     }
     return info2;
 }
예제 #5
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();
                    }
                }
            }
        }