コード例 #1
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            ComponentServices.InitializeRemotingChannels();
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            object data = CallContext.GetData("__ClientIsClr");

            if ((data != null) && ((bool)data))
            {
                RemoteServicedComponentProxy proxy = this._rp as RemoteServicedComponentProxy;
                if (proxy != null)
                {
                    RemotingServices.Marshal((MarshalByRefObject)proxy.RemotingIntermediary.GetTransparentProxy(), null, null).GetObjectData(info, context);
                }
                else
                {
                    base.GetObjectData(info, context);
                }
            }
            else
            {
                base.GetObjectData(info, context);
                info.SetType(typeof(ServicedComponentMarshaler));
                info.AddValue("servertype", this._rp.GetProxiedType());
                byte[] dCOMBuffer = ComponentServices.GetDCOMBuffer((MarshalByRefObject)this._rp.GetTransparentProxy());
                if (dCOMBuffer != null)
                {
                    info.AddValue("dcomInfo", dCOMBuffer);
                }
            }
        }
コード例 #2
0
        // copied from ServicedComponentMarshaler above directly
        // IF YOU MAK ANY CHANGES TO THIS, KEEP THE OTHER COPY IN SYNC
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            DBG.Info(DBG.SC, "FSCM: GetObjectData");
            ComponentServices.InitializeRemotingChannels();
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            // Check to see if this is a remoting channel, if so, then we
            // should use the standard objref marshal (cause we're going over SOAP
            // or another remoting channel).
            object oClientIsClr = CallContext.GetData("__ClientIsClr");

            DBG.Info(DBG.SC, "FSCM: GetObjectData: oClientIsClr = " + oClientIsClr);
            bool bUseStandardObjRef = (oClientIsClr == null)?false:(bool)oClientIsClr;

            if (bUseStandardObjRef)
            {
                RemoteServicedComponentProxy rscp = _rp as RemoteServicedComponentProxy;
                if (rscp != null)
                {
                    DBG.Info(DBG.SC, "FSCM: GetObjectData: intermediary objref");
                    ObjRef std = RemotingServices.Marshal((MarshalByRefObject)(rscp.RemotingIntermediary.GetTransparentProxy()), null, null);
                    std.GetObjectData(info, context);
                }
                else
                {
                    DBG.Info(DBG.SC, "FSCM: GetObjectData: Using standard objref");
                    base.GetObjectData(info, context);
                }
            }
            else
            {
                DBG.Info(DBG.SC, "FSCM: GetObjectData: Using custom objref");
                base.GetObjectData(info, context);

                //*** base.GetObjectData sets the type to be itself
                // now wack the type to be us
                info.SetType(typeof(ServicedComponentMarshaler));

                DBG.Assert(_rp != null, "_rp is null");

                info.AddValue("servertype", _rp.GetProxiedType());

                byte[] dcomBuffer = ComponentServices.GetDCOMBuffer((MarshalByRefObject)_rp.GetTransparentProxy());

                DBG.Assert(dcomBuffer != null, "dcomBuffer is null");

                if (dcomBuffer != null)
                {
                    info.AddValue("dcomInfo", dcomBuffer);
                }
            }
        }
コード例 #3
0
        protected ServicedComponentMarshaler(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            byte[] buffer              = null;
            Type   servertype          = null;
            bool   bFoundFIsMarshalled = false;

            DBG.Info(DBG.SC, "SCM: construct");
            ComponentServices.InitializeRemotingChannels();
            SerializationInfoEnumerator e = info.GetEnumerator();

            while (e.MoveNext())
            {
                DBG.Info(DBG.SC, "SCM: ctor: name = " + e.Name + " value = " + e.Value);
                if (e.Name.Equals("servertype"))
                {
                    servertype = (Type)e.Value;
                }
                else if (e.Name.Equals("dcomInfo"))
                {
                    buffer = (byte[])e.Value;
                }
                else if (e.Name.Equals("fIsMarshalled"))
                {
                    int    value = 0;
                    Object o     = e.Value;
                    if (o.GetType() == typeof(String))
                    {
                        value = ((IConvertible)o).ToInt32(null);
                    }
                    else
                    {
                        value = (int)o;
                    }

                    if (value == 0)
                    {
                        bFoundFIsMarshalled = true;
                    }
                }
            }

            if (!bFoundFIsMarshalled)
            {
                DBG.Info(DBG.SC, "SCM: ctor: didn't find fIsMarshalled.");
                _marshalled = true;
            }

            _um = new SCUnMarshaler(servertype, buffer);

            _rt = servertype;


            if (IsFromThisProcess() && !ServicedComponentInfo.IsTypeEventSource(servertype))
            {
                _rp = RemotingServices.GetRealProxy(base.GetRealObject(context));
            }
            else
            {
                DBG.Assert(servertype != null, "SCM: server type is null during marshal.");
                if (ServicedComponentInfo.IsTypeEventSource(servertype))
                {
                    TypeInfo = (IRemotingTypeInfo) new SCMTypeName(servertype);
                }
                Object otp = base.GetRealObject(context);
                _rp = RemotingServices.GetRealProxy(otp);
            }
            // cleanup the buffer, in case we found an existing rp
            _um.Dispose();
        }
        protected ServicedComponentMarshaler(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            byte[] buffer = null;
            Type   type   = null;
            bool   flag   = false;

            ComponentServices.InitializeRemotingChannels();
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Name.Equals("servertype"))
                {
                    type = (Type)enumerator.Value;
                }
                else
                {
                    if (enumerator.Name.Equals("dcomInfo"))
                    {
                        buffer = (byte[])enumerator.Value;
                        continue;
                    }
                    if (enumerator.Name.Equals("fIsMarshalled"))
                    {
                        int    num  = 0;
                        object obj2 = enumerator.Value;
                        if (obj2.GetType() == typeof(string))
                        {
                            num = ((IConvertible)obj2).ToInt32(null);
                        }
                        else
                        {
                            num = (int)obj2;
                        }
                        if (num == 0)
                        {
                            flag = true;
                        }
                    }
                }
            }
            if (!flag)
            {
                this._marshalled = true;
            }
            this._um = new SCUnMarshaler(type, buffer);
            this._rt = type;
            if (base.IsFromThisProcess() && !ServicedComponentInfo.IsTypeEventSource(type))
            {
                this._rp = RemotingServices.GetRealProxy(base.GetRealObject(context));
            }
            else
            {
                if (ServicedComponentInfo.IsTypeEventSource(type))
                {
                    this.TypeInfo = new SCMTypeName(type);
                }
                object realObject = base.GetRealObject(context);
                this._rp = RemotingServices.GetRealProxy(realObject);
            }
            this._um.Dispose();
        }