System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage C# (CSharp) Method

CallProcessMessage() static private method

static private CallProcessMessage ( IMessageSink ms, IMessage reqMsg, ArrayWithSize proxySinks, Thread currentThread, Context currentContext, bool bSkippingContextChain ) : IMessage
ms IMessageSink
reqMsg IMessage
proxySinks System.Runtime.Remoting.Contexts.ArrayWithSize
currentThread Thread
currentContext System.Runtime.Remoting.Contexts.Context
bSkippingContextChain bool
return IMessage
        internal static IMessage CallProcessMessage(IMessageSink ms, 
                                                    IMessage reqMsg, 
                                                    ArrayWithSize proxySinks,
                                                    Thread currentThread,
                                                    Context currentContext,
                                                    bool bSkippingContextChain)
        {                   
            // Notify Dynamic Sinks: CALL starting          
            if (proxySinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(
                                            reqMsg, 
                                            proxySinks, 
                                            true,   // bCliSide
                                            true,   // bStart
                                            false); // bAsync
            }

            bool bHasDynamicSinks = false;
            if (bSkippingContextChain)
            {
                // this would have been done in the client context terminator sink
                bHasDynamicSinks = 
                    currentContext.NotifyDynamicSinks(reqMsg, 
                        true,   // bCliSide
                        true,   // bStart
                        false,  // bAsync
                        true);  // bNotifyGlobals 
   
                ChannelServices.NotifyProfiler(reqMsg, RemotingProfilerEvent.ClientSend);
            }
            
            if (ms == null)
            {
                throw new RemotingException(
                    Environment.GetResourceString(
                        "Remoting_Proxy_NoChannelSink"));                    
            }

            IMessage retMsg = ms.SyncProcessMessage(reqMsg);

            if (bSkippingContextChain)
            {
                // this would have been done in the client context terminator sink
                ChannelServices.NotifyProfiler(retMsg, RemotingProfilerEvent.ClientReceive);

                if (bHasDynamicSinks)
                {
                    currentContext.NotifyDynamicSinks(
                        retMsg, 
                        true,   // bCliSide
                        false,   // bStart
                        false,  // bAsync
                        true);  // bNotifyGlobals  
                }
            }            

            IMethodReturnMessage mrm = retMsg as IMethodReturnMessage;
            if (retMsg == null || mrm == null)
            {
                throw new RemotingException(
                    Environment.GetResourceString("Remoting_Message_BadType"));                    
            }

            // notify DynamicSinks: CALL returned
            if (proxySinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(
                                            retMsg, 
                                            proxySinks, 
                                            true,   // bCliSide
                                            false,  // bStart
                                            false); // bAsync
            }

           
            return retMsg;
        }

Usage Example

Beispiel #1
0
        internal virtual IMessage InternalInvoke(IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType)
        {
            Message message1 = reqMcmMsg as Message;

            if (message1 == null && callType != 0)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_InvalidCallType"));
            }
            IMessage           message2           = (IMessage)null;
            Thread             currentThread      = Thread.CurrentThread;
            LogicalCallContext logicalCallContext = currentThread.GetMutableExecutionContext().LogicalCallContext;
            Identity           identityObject     = this.IdentityObject;
            ServerIdentity     serverIdentity     = identityObject as ServerIdentity;

            if (serverIdentity != null && identityObject.IsFullyDisconnected())
            {
                throw new ArgumentException(Environment.GetResourceString("Remoting_ServerObjectNotFound", (object)reqMcmMsg.Uri));
            }
            MethodBase methodBase = reqMcmMsg.MethodBase;

            if ((MethodBase)RemotingProxy._getTypeMethod == methodBase)
            {
                return((IMessage) new ReturnMessage((object)this.GetProxiedType(), (object[])null, 0, logicalCallContext, reqMcmMsg));
            }
            if ((MethodBase)RemotingProxy._getHashCodeMethod == methodBase)
            {
                return((IMessage) new ReturnMessage((object)identityObject.GetHashCode(), (object[])null, 0, logicalCallContext, reqMcmMsg));
            }
            if (identityObject.ChannelSink == null)
            {
                IMessageSink chnlSink  = (IMessageSink)null;
                IMessageSink envoySink = (IMessageSink)null;
                if (!identityObject.ObjectRef.IsObjRefLite())
                {
                    RemotingServices.CreateEnvoyAndChannelSinks((MarshalByRefObject)null, identityObject.ObjectRef, out chnlSink, out envoySink);
                }
                else
                {
                    RemotingServices.CreateEnvoyAndChannelSinks(identityObject.ObjURI, (object)null, out chnlSink, out envoySink);
                }
                RemotingServices.SetEnvoyAndChannelSinks(identityObject, chnlSink, envoySink);
                if (identityObject.ChannelSink == null)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_NoChannelSink"));
                }
            }
            IInternalMessage internalMessage = (IInternalMessage)reqMcmMsg;

            internalMessage.IdentityObject = identityObject;
            if (serverIdentity != null)
            {
                internalMessage.ServerIdentityObject = serverIdentity;
            }
            else
            {
                internalMessage.SetURI(identityObject.URI);
            }
            switch (callType)
            {
            case 0:
                bool         bSkippingContextChain  = false;
                Context      currentContextInternal = currentThread.GetCurrentContextInternal();
                IMessageSink ms = identityObject.EnvoyChain;
                if (currentContextInternal.IsDefaultContext && ms is EnvoyTerminatorSink)
                {
                    bSkippingContextChain = true;
                    ms = identityObject.ChannelSink;
                }
                message2 = RemotingProxy.CallProcessMessage(ms, (IMessage)reqMcmMsg, identityObject.ProxySideDynamicSinks, currentThread, currentContextInternal, bSkippingContextChain);
                break;

            case 1:
            case 9:
                LogicalCallContext callContext1 = (LogicalCallContext)logicalCallContext.Clone();
                internalMessage.SetCallContext(callContext1);
                AsyncResult asyncResult = new AsyncResult(message1);
                this.InternalInvokeAsync((IMessageSink)asyncResult, message1, useDispatchMessage, callType);
                message2 = (IMessage) new ReturnMessage((object)asyncResult, (object[])null, 0, (LogicalCallContext)null, (IMethodCallMessage)message1);
                break;

            case 2:
                message2 = RealProxy.EndInvokeHelper(message1, true);
                break;

            case 8:
                LogicalCallContext callContext2 = (LogicalCallContext)logicalCallContext.Clone();
                internalMessage.SetCallContext(callContext2);
                this.InternalInvokeAsync((IMessageSink)null, message1, useDispatchMessage, callType);
                message2 = (IMessage) new ReturnMessage((object)null, (object[])null, 0, (LogicalCallContext)null, reqMcmMsg);
                break;

            case 10:
                message2 = (IMessage) new ReturnMessage((object)null, (object[])null, 0, (LogicalCallContext)null, reqMcmMsg);
                break;
            }
            return(message2);
        }