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
示例#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);
        }