Exemplo n.º 1
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo info = null;

            if (null != serverID)
            {
                // Set the envoy sink chain
                if (serverID.EnvoyChain == null)
                {
                    serverID.RaceSetEnvoyChain(
                        serverID.ServerContext.CreateEnvoyChain(
                            serverID.TPOrObject));
                }

                // Create an envoy info object only if necessary
                IMessageSink sink = serverID.EnvoyChain as EnvoyTerminatorSink;
                if (null == sink)
                {
                    // The chain consists of more than a terminator sink
                    // Go ahead and create an envoy info structure, otherwise
                    // a null is returned and we recreate the terminator sink
                    // on the other side, automatically.
                    info = new EnvoyInfo(serverID.EnvoyChain);
                }
            }

            return(info);
        }
Exemplo n.º 2
0
        protected ObjRef(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator en = info.GetEnumerator();
            // Info to serialize: uri, objrefFlags, typeInfo, envoyInfo, channelInfo

            bool marshalledValue = true;

            while (en.MoveNext())
            {
                switch (en.Name)
                {
                case "uri":
                    uri = (string)en.Value;
                    break;

                case "typeInfo":
                    typeInfo = (IRemotingTypeInfo)en.Value;
                    break;

                case "channelInfo":
                    channel_info = (IChannelInfo)en.Value;
                    break;

                case "envoyInfo":
                    envoyInfo = (IEnvoyInfo)en.Value;
                    break;

                case "fIsMarshalled":
                    int    status;
                    Object o = en.Value;
                    if (o is string)
                    {
                        status = ((IConvertible)o).ToInt32(null);
                    }
                    else
                    {
                        status = (int)o;
                    }

                    if (status == 0)
                    {
                        marshalledValue = false;
                    }
                    break;

                case "objrefFlags":
                    flags = Convert.ToInt32(en.Value);
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
            if (marshalledValue)
            {
                flags |= MarshalledObjectRef;
            }
        }
Exemplo n.º 3
0
        protected ObjRef(SerializationInfo info, StreamingContext context)
        {
            string str  = (string)null;
            bool   flag = false;
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Name.Equals("uri"))
                {
                    this.uri = (string)enumerator.Value;
                }
                else if (enumerator.Name.Equals("typeInfo"))
                {
                    this.typeInfo = (IRemotingTypeInfo)enumerator.Value;
                }
                else if (enumerator.Name.Equals("envoyInfo"))
                {
                    this.envoyInfo = (IEnvoyInfo)enumerator.Value;
                }
                else if (enumerator.Name.Equals("channelInfo"))
                {
                    this.channelInfo = (IChannelInfo)enumerator.Value;
                }
                else if (enumerator.Name.Equals("objrefFlags"))
                {
                    object obj = enumerator.Value;
                    this.objrefFlags = !(obj.GetType() == typeof(string)) ? (int)obj : ((IConvertible)obj).ToInt32((IFormatProvider)null);
                }
                else if (enumerator.Name.Equals("fIsMarshalled"))
                {
                    object obj = enumerator.Value;
                    if ((!(obj.GetType() == typeof(string)) ? (int)obj : ((IConvertible)obj).ToInt32((IFormatProvider)null)) == 0)
                    {
                        flag = true;
                    }
                }
                else if (enumerator.Name.Equals("url"))
                {
                    str = (string)enumerator.Value;
                }
                else if (enumerator.Name.Equals("SrvIdentity"))
                {
                    this.SetServerIdentity((GCHandle)enumerator.Value);
                }
                else if (enumerator.Name.Equals("DomainId"))
                {
                    this.SetDomainID((int)enumerator.Value);
                }
            }
            this.objrefFlags = flag ? this.objrefFlags & -2 : this.objrefFlags | 1;
            if (str == null)
            {
                return;
            }
            this.uri         = str;
            this.objrefFlags = this.objrefFlags | 4;
        }
Exemplo n.º 4
0
		internal ObjRef (ObjRef o, bool unmarshalAsProxy) {
			channel_info = o.channel_info;
			uri = o.uri;
	
			typeInfo = o.typeInfo;
			envoyInfo = o.envoyInfo;
			flags = o.flags;
			if (unmarshalAsProxy) flags |= MarshalledObjectRef;
		}
Exemplo n.º 5
0
        /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.ObjRef" /> class from serialized data.</summary>
        /// <param name="info">The object that holds the serialized object data. </param>
        /// <param name="context">The contextual information about the source or destination of the exception. </param>
        protected ObjRef(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();
            bool flag = true;

            while (enumerator.MoveNext())
            {
                string name = enumerator.Name;
                switch (name)
                {
                case "uri":
                    this.uri = (string)enumerator.Value;
                    continue;

                case "typeInfo":
                    this.typeInfo = (IRemotingTypeInfo)enumerator.Value;
                    continue;

                case "channelInfo":
                    this.channel_info = (IChannelInfo)enumerator.Value;
                    continue;

                case "envoyInfo":
                    this.envoyInfo = (IEnvoyInfo)enumerator.Value;
                    continue;

                case "fIsMarshalled":
                {
                    object value = enumerator.Value;
                    int    num2;
                    if (value is string)
                    {
                        num2 = ((IConvertible)value).ToInt32(null);
                    }
                    else
                    {
                        num2 = (int)value;
                    }
                    if (num2 == 0)
                    {
                        flag = false;
                    }
                    continue;
                }

                case "objrefFlags":
                    this.flags = Convert.ToInt32(enumerator.Value);
                    continue;
                }
                throw new NotSupportedException();
            }
            if (flag)
            {
                this.flags |= ObjRef.MarshalledObjectRef;
            }
        }
 private ObjRef(ObjRef o)
 {
     this.uri = o.uri;
     this.typeInfo = o.typeInfo;
     this.envoyInfo = o.envoyInfo;
     this.channelInfo = o.channelInfo;
     this.objrefFlags = o.objrefFlags;
     this.SetServerIdentity(o.GetServerIdentity());
     this.SetDomainID(o.GetDomainID());
 }
Exemplo n.º 7
0
        // shallow copy constructor used for smuggling.
        private ObjRef(ObjRef o)
        {
            BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef");

            uri         = o.uri;
            typeInfo    = o.typeInfo;
            envoyInfo   = o.envoyInfo;
            channelInfo = o.channelInfo;
            objrefFlags = o.objrefFlags;
        } // ObjRef
Exemplo n.º 8
0
 private ObjRef(ObjRef o)
 {
     this.uri         = o.uri;
     this.typeInfo    = o.typeInfo;
     this.envoyInfo   = o.envoyInfo;
     this.channelInfo = o.channelInfo;
     this.objrefFlags = o.objrefFlags;
     this.SetServerIdentity(o.GetServerIdentity());
     this.SetDomainID(o.GetDomainID());
 }
Exemplo n.º 9
0
        // shallow copy constructor used for smuggling.
        private ObjRef(ObjRef o)
        {
            BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef");

            uri         = o.uri;
            typeInfo    = o.typeInfo;
            envoyInfo   = o.envoyInfo;
            channelInfo = o.channelInfo;
            objrefFlags = o.objrefFlags;
            SetServerIdentity(o.GetServerIdentity());
            SetDomainID(o.GetDomainID());
        } // ObjRef
Exemplo n.º 10
0
 internal ObjRef(ObjRef o, bool unmarshalAsProxy)
 {
     this.channel_info = o.channel_info;
     this.uri          = o.uri;
     this.typeInfo     = o.typeInfo;
     this.envoyInfo    = o.envoyInfo;
     this.flags        = o.flags;
     if (unmarshalAsProxy)
     {
         this.flags |= ObjRef.MarshalledObjectRef;
     }
 }
Exemplo n.º 11
0
        internal ObjRef(ObjRef o, bool unmarshalAsProxy)
        {
            channel_info = o.channel_info;
            uri          = o.uri;

            typeInfo  = o.typeInfo;
            envoyInfo = o.envoyInfo;
            flags     = o.flags;
            if (unmarshalAsProxy)
            {
                flags |= MarshalledObjectRef;
            }
        }
Exemplo n.º 12
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo result = null;

            if (serverID != null)
            {
                if (serverID.EnvoyChain == null)
                {
                    serverID.RaceSetEnvoyChain(serverID.ServerContext.CreateEnvoyChain(serverID.TPOrObject));
                }
                if (!(serverID.EnvoyChain is EnvoyTerminatorSink))
                {
                    result = new EnvoyInfo(serverID.EnvoyChain);
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo envoyInfo = (IEnvoyInfo)null;

            if (serverID != null)
            {
                if (serverID.EnvoyChain == null)
                {
                    ServerIdentity serverIdentity = serverID;
                    IMessageSink   envoyChain     = serverIdentity.ServerContext.CreateEnvoyChain(serverID.TPOrObject);
                    serverIdentity.RaceSetEnvoyChain(envoyChain);
                }
                if ((IMessageSink)(serverID.EnvoyChain as EnvoyTerminatorSink) == null)
                {
                    envoyInfo = (IEnvoyInfo) new EnvoyInfo(serverID.EnvoyChain);
                }
            }
            return(envoyInfo);
        }
Exemplo n.º 14
0
    public static void Main()
    {
        ChannelServices.RegisterChannel(new HttpChannel(0));
        RemotingConfiguration.RegisterActivatedClientType(typeof(SampleService), "http://localhost:9000/MySampleService");
        SampleService myRemoteObject = new SampleService();
        bool          result         = myRemoteObject.SampleMethod();
        // System.Runtime.Remoting.RemotingServices.GetObjRefForProxy

        // <Snippet1>
        ObjRef objRefSample = RemotingServices.GetObjRefForProxy(myRemoteObject);

        Console.WriteLine("***ObjRef Details***");
        Console.WriteLine("URI:\t{0}", objRefSample.URI);

        object[] channelData = objRefSample.ChannelInfo.ChannelData;

        Console.WriteLine("Channel Info:");
        foreach (object o in channelData)
        {
            Console.WriteLine("\t{0}", o.ToString());
        }

        IEnvoyInfo envoyInfo = objRefSample.EnvoyInfo;

        if (envoyInfo == null)
        {
            Console.WriteLine("This ObjRef does not have envoy information.");
        }
        else
        {
            IMessageSink envoySinks = envoyInfo.EnvoySinks;
            Console.WriteLine("Envoy Sink Class: {0}", envoySinks);
        }

        IRemotingTypeInfo typeInfo = objRefSample.TypeInfo;

        Console.WriteLine("Remote type name: {0}", typeInfo.TypeName);

        Console.WriteLine("Can my object cast to a Bitmap? {0}",
                          typeInfo.CanCastTo(typeof(System.Drawing.Bitmap), objRefSample));
        // </Snippet1>
    }
Exemplo n.º 15
0
		/// <include file='doc\ObjRef.uex' path='docs/doc[@for="ObjRef.ObjRef2"]/*' />
		protected ObjRef(SerializationInfo info, StreamingContext context) 
        {
            String url = null; // an objref lite url
            bool bFoundFIsMarshalled = false;
        
        	SerializationInfoEnumerator e = info.GetEnumerator();
            while (e.MoveNext())
            {
                if (e.Name.Equals("uri"))
                {
                    uri = (String) e.Value;
                }
                else if (e.Name.Equals("typeInfo"))
                {
                    typeInfo = (IRemotingTypeInfo) e.Value;
                }
                else if (e.Name.Equals("envoyInfo"))
                {
                    envoyInfo = (IEnvoyInfo) e.Value;
                }
                else if (e.Name.Equals("channelInfo"))
                {
                    channelInfo = (IChannelInfo) e.Value;
                }
                else if (e.Name.Equals("objrefFlags"))
                {
                	Object o = e.Value;
                	if(o.GetType() == typeof(String))
                	{
                		objrefFlags = ((IConvertible)o).ToInt32(null);
                	}
                	else
                	{
                    	objrefFlags = (int)o;
                    }
                }
                else if (e.Name.Equals("fIsMarshalled"))
                {
                    int value;
                    Object o = e.Value;
                    if(o.GetType() == typeof(String))
                		value = ((IConvertible)o).ToInt32(null);
                	else
                    	value = (int)o;

                    if (value == 0)
                        bFoundFIsMarshalled = true;                                        
				}            
				else if (e.Name.Equals("url"))
				{
				    url = (String)e.Value;
				}
            }

            if (!bFoundFIsMarshalled)
            {
                // This ObjRef was not passed as a parameter, so we need to unmarshal it.
                objrefFlags |= FLG_MARSHALED_OBJECT; 
            }

            // If only url is present, then it is an ObjRefLite.
            if (url != null)
            {
                uri = url;
                objrefFlags |= FLG_LITE_OBJREF;
            }
            
        } // ObjRef .ctor
Exemplo n.º 16
0
        // shallow copy constructor used for smuggling.
        private ObjRef(ObjRef o)
        {
            BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef");

            uri = o.uri;
            typeInfo = o.typeInfo;
            envoyInfo = o.envoyInfo;
            channelInfo = o.channelInfo;
            objrefFlags = o.objrefFlags;
        } // ObjRef
Exemplo n.º 17
0
        protected ObjRef(SerializationInfo info, StreamingContext context)
        {
            String url = null; // an objref lite url
            bool   bFoundFIsMarshalled = false;

            SerializationInfoEnumerator e = info.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Name.Equals("uri"))
                {
                    uri = (String)e.Value;
                }
                else if (e.Name.Equals("typeInfo"))
                {
                    typeInfo = (IRemotingTypeInfo)e.Value;
                }
                else if (e.Name.Equals("envoyInfo"))
                {
                    envoyInfo = (IEnvoyInfo)e.Value;
                }
                else if (e.Name.Equals("channelInfo"))
                {
                    channelInfo = (IChannelInfo)e.Value;
                }
                else if (e.Name.Equals("objrefFlags"))
                {
                    Object o = e.Value;
                    if (o.GetType() == typeof(String))
                    {
                        objrefFlags = ((IConvertible)o).ToInt32(null);
                    }
                    else
                    {
                        objrefFlags = (int)o;
                    }
                }
                else if (e.Name.Equals("fIsMarshalled"))
                {
                    int    value;
                    Object o = e.Value;
                    if (o.GetType() == typeof(String))
                    {
                        value = ((IConvertible)o).ToInt32(null);
                    }
                    else
                    {
                        value = (int)o;
                    }

                    if (value == 0)
                    {
                        bFoundFIsMarshalled = true;
                    }
                }
                else if (e.Name.Equals("url"))
                {
                    url = (String)e.Value;
                }
                else if (e.Name.Equals("SrvIdentity"))
                {
                    SetServerIdentity((GCHandle)e.Value);
                }
                else if (e.Name.Equals("DomainId"))
                {
                    SetDomainID((int)e.Value);
                }
            }

            if (!bFoundFIsMarshalled)
            {
                // This ObjRef was not passed as a parameter, so we need to unmarshal it.
                objrefFlags |= FLG_MARSHALED_OBJECT;
            }
            else
            {
                objrefFlags &= ~FLG_MARSHALED_OBJECT;
            }

            // If only url is present, then it is an ObjRefLite.
            if (url != null)
            {
                uri          = url;
                objrefFlags |= FLG_LITE_OBJREF;
            }
        } // ObjRef .ctor
Exemplo n.º 18
0
        protected ObjRef(SerializationInfo info, StreamingContext context)
        {
            string str  = null;
            bool   flag = false;
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Name.Equals("uri"))
                {
                    this.uri = (string)enumerator.Value;
                }
                else
                {
                    if (enumerator.Name.Equals("typeInfo"))
                    {
                        this.typeInfo = (IRemotingTypeInfo)enumerator.Value;
                        continue;
                    }
                    if (enumerator.Name.Equals("envoyInfo"))
                    {
                        this.envoyInfo = (IEnvoyInfo)enumerator.Value;
                        continue;
                    }
                    if (enumerator.Name.Equals("channelInfo"))
                    {
                        this.channelInfo = (IChannelInfo)enumerator.Value;
                        continue;
                    }
                    if (enumerator.Name.Equals("objrefFlags"))
                    {
                        object obj2 = enumerator.Value;
                        if (obj2.GetType() == typeof(string))
                        {
                            this.objrefFlags = ((IConvertible)obj2).ToInt32(null);
                        }
                        else
                        {
                            this.objrefFlags = (int)obj2;
                        }
                        continue;
                    }
                    if (enumerator.Name.Equals("fIsMarshalled"))
                    {
                        int    num;
                        object obj3 = enumerator.Value;
                        if (obj3.GetType() == typeof(string))
                        {
                            num = ((IConvertible)obj3).ToInt32(null);
                        }
                        else
                        {
                            num = (int)obj3;
                        }
                        if (num == 0)
                        {
                            flag = true;
                        }
                        continue;
                    }
                    if (enumerator.Name.Equals("url"))
                    {
                        str = (string)enumerator.Value;
                    }
                    else
                    {
                        if (enumerator.Name.Equals("SrvIdentity"))
                        {
                            this.SetServerIdentity((GCHandle)enumerator.Value);
                            continue;
                        }
                        if (enumerator.Name.Equals("DomainId"))
                        {
                            this.SetDomainID((int)enumerator.Value);
                        }
                    }
                }
            }
            if (!flag)
            {
                this.objrefFlags |= 1;
            }
            else
            {
                this.objrefFlags &= -2;
            }
            if (str != null)
            {
                this.uri          = str;
                this.objrefFlags |= 4;
            }
        }
Exemplo n.º 19
0
		protected ObjRef (SerializationInfo info, StreamingContext context)
		{
			SerializationInfoEnumerator en = info.GetEnumerator();
			// Info to serialize: uri, objrefFlags, typeInfo, envoyInfo, channelInfo

			bool marshalledValue = true;

			while (en.MoveNext ()) {
				switch (en.Name) {
				case "uri":
					uri = (string)en.Value;
					break;
				case "typeInfo":
					typeInfo = (IRemotingTypeInfo)en.Value;
					break;
				case "channelInfo":
					channel_info = (IChannelInfo)en.Value;
					break;
				case "envoyInfo":
					envoyInfo = (IEnvoyInfo)en.Value;
					break;
				case "fIsMarshalled":
					int status;
					Object o = en.Value;
					if (o is string)
						status = ((IConvertible) o).ToInt32(null);
					else
						status = (int) o;

					if (status == 0)
						marshalledValue = false;
					break;
				case "objrefFlags":
					flags = Convert.ToInt32 (en.Value);
					break;
				default:
					throw new NotSupportedException ();
				}
			}
			if (marshalledValue) flags |= MarshalledObjectRef;
		}
Exemplo n.º 20
0
        [System.Security.SecurityCritical]  // auto-generated
        private ObjRef(ObjRef o)
        {
            BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef"); 

            uri = o.uri; 
            typeInfo = o.typeInfo; 
            envoyInfo = o.envoyInfo;
            channelInfo = o.channelInfo; 
            objrefFlags = o.objrefFlags;
            SetServerIdentity(o.GetServerIdentity());
            SetDomainID(o.GetDomainID());
        } // ObjRef 
 protected ObjRef(SerializationInfo info, StreamingContext context)
 {
     string str = null;
     bool flag = false;
     SerializationInfoEnumerator enumerator = info.GetEnumerator();
     while (enumerator.MoveNext())
     {
         if (enumerator.Name.Equals("uri"))
         {
             this.uri = (string) enumerator.Value;
         }
         else
         {
             if (enumerator.Name.Equals("typeInfo"))
             {
                 this.typeInfo = (IRemotingTypeInfo) enumerator.Value;
                 continue;
             }
             if (enumerator.Name.Equals("envoyInfo"))
             {
                 this.envoyInfo = (IEnvoyInfo) enumerator.Value;
                 continue;
             }
             if (enumerator.Name.Equals("channelInfo"))
             {
                 this.channelInfo = (IChannelInfo) enumerator.Value;
                 continue;
             }
             if (enumerator.Name.Equals("objrefFlags"))
             {
                 object obj2 = enumerator.Value;
                 if (obj2.GetType() == typeof(string))
                 {
                     this.objrefFlags = ((IConvertible) obj2).ToInt32(null);
                 }
                 else
                 {
                     this.objrefFlags = (int) obj2;
                 }
                 continue;
             }
             if (enumerator.Name.Equals("fIsMarshalled"))
             {
                 int num;
                 object obj3 = enumerator.Value;
                 if (obj3.GetType() == typeof(string))
                 {
                     num = ((IConvertible) obj3).ToInt32(null);
                 }
                 else
                 {
                     num = (int) obj3;
                 }
                 if (num == 0)
                 {
                     flag = true;
                 }
                 continue;
             }
             if (enumerator.Name.Equals("url"))
             {
                 str = (string) enumerator.Value;
             }
             else
             {
                 if (enumerator.Name.Equals("SrvIdentity"))
                 {
                     this.SetServerIdentity((GCHandle) enumerator.Value);
                     continue;
                 }
                 if (enumerator.Name.Equals("DomainId"))
                 {
                     this.SetDomainID((int) enumerator.Value);
                 }
             }
         }
     }
     if (!flag)
     {
         this.objrefFlags |= 1;
     }
     else
     {
         this.objrefFlags &= -2;
     }
     if (str != null)
     {
         this.uri = str;
         this.objrefFlags |= 4;
     }
 }