Esempio n. 1
0
        public override Object GetRealObject(StreamingContext context)
        {
            DBG.Info(DBG.SC, "SCM: GetRealObject()");

            if (!IsMarshaledObject)
            {
                DBG.Info(DBG.SC, "SCM: GetRealObject() returning objref!");
                return(this);
            }
            else
            {
                if (IsFromThisProcess() && !ServicedComponentInfo.IsTypeEventSource(_rt))
                {
                    Object otp = base.GetRealObject(context);
                    // We need to notify the object that there is a managed reference.
                    ((ServicedComponent)otp).DoSetCOMIUnknown(IntPtr.Zero);

                    return(otp);
                }
                else
                {
                    if (_rp == null)
                    {
                        _rp = _um.GetRealProxy();
                    }
                    DBG.Assert(_rp != null, "GetRealObject on a marshaller with no proxy!");
                    return(_rp.GetTransparentProxy());
                }
            }
        }
Esempio n. 2
0
        public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
        {
            object transparentProxy = oldcp.GetTransparentProxy();
            object tp = newcp.GetTransparentProxy();

            RemotingServices.GetServerContextForProxy(transparentProxy);
            RemotingServices.GetServerContextForProxy(tp);
            Marshal.InternalSwitchCCW(transparentProxy, tp);
        }
        public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
        {
            Object oldtp = oldcp.GetTransparentProxy();
            Object newtp = newcp.GetTransparentProxy();

            int oldcontextId = RemotingServices.GetServerContextForProxy(oldtp);
            int newcontextId = RemotingServices.GetServerContextForProxy(newtp);

            // switch the CCW from oldtp to new tp
            Marshal.SwitchCCW(oldtp, newtp);
        }
Esempio n. 4
0
 void IDisposable.Dispose()
 {
     if (serviceProxy != null)
     {
         IChannel channel = serviceProxy.GetTransparentProxy() as IChannel;
         if (channel == null)
         {
             throw Fx.AssertAndThrow("serviceProxy MUST support IChannel");
         }
         channel.Close();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Вызов методов.
        /// Стоит обратить внимание, что в момент вызова этого метода
        /// значение свойства Context.InternalContextID == __TP.stubData
        ///	В противном случае вызов RemotingServices.ExecuteMessage приведет к зацикливанию.
        /// </summary>
        public void Execute()
        {
            // валидация
            if (validationOnAction != null)
            {
                validationOnAction(callMessage as IMethodCallMessage);
            }

            ReturnMessage = RemotingServices.ExecuteMessage(
                (MarshalByRefObject)proxy.GetTransparentProxy(),
                (IMethodCallMessage)callMessage);
        }
Esempio n. 6
0
        // Convert from the local representative of the sponsor to either the MarshalByRefObject or local object
        private ISponsor GetSponsorFromId(Object sponsorId)
        {
            Object    sponsor = null;
            RealProxy rp      = sponsorId as RealProxy;

            if (null != rp)
            {
                sponsor = rp.GetTransparentProxy();
            }
            else
            {
                sponsor = sponsorId;
            }
            return((ISponsor)sponsor);
        }
        private ISponsor GetSponsorFromId(object sponsorId)
        {
            object    transparentProxy = null;
            RealProxy proxy            = sponsorId as RealProxy;

            if (proxy != null)
            {
                transparentProxy = proxy.GetTransparentProxy();
            }
            else
            {
                transparentProxy = sponsorId;
            }
            return((ISponsor)transparentProxy);
        }
Esempio n. 8
0
        /// <summary>
        /// 获取对象的代理
        /// </summary>
        /// <param name="type">该类型必须为 ServiceAbstract 类型的子类</param>
        /// <param name="instance"></param>
        /// <param name="delay"></param>
        /// <returns></returns>
        private static object GetTransparentProxy(Type type, object instance, bool delay)
        {
            if (!type.IsSubclassOf(typeof(MarshalByRefObject)))
            {
                throw new Exception("所代理的对象的类型必须为 ServiceAbstract 类型的子类");
            }

            Type tmpType = typeof(DelayProxy <>);

            tmpType = tmpType.MakeGenericType(type);

            RealProxy proxy = Activator.CreateInstance(tmpType, new object[] { instance, delay }) as RealProxy;

            return(proxy.GetTransparentProxy());
        }
Esempio n. 9
0
        private ISponsor GetSponsorFromId(object sponsorId)
        {
            RealProxy realProxy = sponsorId as RealProxy;
            object    obj;

            if (realProxy != null)
            {
                obj = realProxy.GetTransparentProxy();
            }
            else
            {
                obj = sponsorId;
            }
            return((ISponsor)obj);
        }
Esempio n. 10
0
 /// <summary>
 /// Gets the client proxy interface that provides calling client methods remotely.
 /// </summary>
 /// <typeparam name="T">Type of client interface</typeparam>
 /// <returns>Client interface</returns>
 public T GetClientProxy <T>() where T : class
 {
     _realProxy = new RemoteInvokeProxy <T, IScsServerClient>(_requestReplyMessenger);
     return((T)_realProxy.GetTransparentProxy());
 }
 public object GetObject()
 {
     return(realProxy.GetTransparentProxy());
 }
Esempio n. 12
0
 public override object GetTransparentProxy()
 {
     return(innerProxy.GetTransparentProxy());
 }
Esempio n. 13
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);
                }
            }
        }
Esempio n. 14
0
        private ISponsor GetSponsorFromId(object sponsorId)
        {
            RealProxy realProxy = sponsorId as RealProxy;

            return(realProxy == null ? (ISponsor)sponsorId : (ISponsor)realProxy.GetTransparentProxy());
        }