public virtual IMessage SyncProcessMessage(IMessage reqMsg)
        {
            IMessage message2;
            IMessage message = InternalSink.ValidateMessage(reqMsg);

            if (message != null)
            {
                return(message);
            }
            Context currentContext = Thread.CurrentContext;
            bool    flag           = currentContext.NotifyDynamicSinks(reqMsg, true, true, false, true);

            if (reqMsg is IConstructionCallMessage)
            {
                message = currentContext.NotifyActivatorProperties(reqMsg, false);
                if (message != null)
                {
                    return(message);
                }
                message2 = ((IConstructionCallMessage)reqMsg).Activator.Activate((IConstructionCallMessage)reqMsg);
                message  = currentContext.NotifyActivatorProperties(message2, false);
                if (message != null)
                {
                    return(message);
                }
            }
            else
            {
                message2 = null;
                ChannelServices.NotifyProfiler(reqMsg, RemotingProfilerEvent.ClientSend);
                object[]     args        = new object[2];
                IMessageSink channelSink = this.GetChannelSink(reqMsg);
                args[0] = reqMsg;
                args[1] = channelSink;
                InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ClientContextTerminatorSink.SyncProcessMessageCallback);
                if (channelSink != CrossContextChannel.MessageSink)
                {
                    message2 = (IMessage)Thread.CurrentThread.InternalCrossContextCallback(Context.DefaultContext, ftnToCall, args);
                }
                else
                {
                    message2 = (IMessage)ftnToCall(args);
                }
                ChannelServices.NotifyProfiler(message2, RemotingProfilerEvent.ClientReceive);
            }
            if (flag)
            {
                currentContext.NotifyDynamicSinks(reqMsg, true, false, false, true);
            }
            return(message2);
        }
Ejemplo n.º 2
0
        internal static IMessage CallProcessMessage(IMessageSink ms, IMessage reqMsg, ArrayWithSize proxySinks, Thread currentThread, Context currentContext, bool bSkippingContextChain)
        {
            if (proxySinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(reqMsg, proxySinks, true, true, false);
            }
            bool flag = false;

            if (bSkippingContextChain)
            {
                flag = currentContext.NotifyDynamicSinks(reqMsg, true, true, false, true);
                ChannelServices.NotifyProfiler(reqMsg, RemotingProfilerEvent.ClientSend);
            }
            if (ms == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_NoChannelSink"));
            }
            IMessage msg = ms.SyncProcessMessage(reqMsg);

            if (bSkippingContextChain)
            {
                ChannelServices.NotifyProfiler(msg, RemotingProfilerEvent.ClientReceive);
                if (flag)
                {
                    currentContext.NotifyDynamicSinks(msg, true, false, false, true);
                }
            }
            IMethodReturnMessage methodReturnMessage = msg as IMethodReturnMessage;

            if (msg == null || methodReturnMessage == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Message_BadType"));
            }
            if (proxySinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(msg, proxySinks, true, false, false);
            }
            return(msg);
        }
Ejemplo n.º 3
0
        // This is used when a TP is called with SyncProcessMessage
        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
            }

            RemotingServices.LogRemotingStage(RemotingServices.CLIENT_MSG_SINK_CHAIN);

            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
            }


            RemotingServices.LogRemotingStage(RemotingServices.CLIENT_RET_PROPAGATION);

            return(retMsg);
        }
        [System.Security.SecurityCritical]  // auto-generated
        public virtual IMessage     SyncProcessMessage(IMessage reqMsg)
        {
            Message.DebugOut("+++++++++++++++++++++++++ CliCtxTerminator: SyncProcessMsg");
            IMessage errMsg = ValidateMessage(reqMsg);

            if (errMsg != null)
            {
                return(errMsg);
            }

            Context ctx = Thread.CurrentContext;

            bool bHasDynamicSinks =
                ctx.NotifyDynamicSinks(reqMsg,
                                       true,  // bCliSide
                                       true,  // bStart
                                       false, // bAsync
                                       true); // bNotifyGlobals

            IMessage replyMsg;

            if (reqMsg is IConstructionCallMessage)
            {
                errMsg = ctx.NotifyActivatorProperties(
                    reqMsg,
                    false /*bServerSide*/);
                if (errMsg != null)
                {
                    return(errMsg);
                }

                replyMsg = ((IConstructionCallMessage)reqMsg).Activator.Activate(
                    (IConstructionCallMessage)reqMsg);
                BCLDebug.Assert(replyMsg is IConstructionReturnMessage, "bad ctorRetMsg");
                errMsg = ctx.NotifyActivatorProperties(
                    replyMsg,
                    false /*bServerSide*/);
                if (errMsg != null)
                {
                    return(errMsg);
                }
            }
            else
            {
                replyMsg = null;
                ChannelServices.NotifyProfiler(reqMsg, RemotingProfilerEvent.ClientSend);

                Object[] args = new Object[] { null, null };

                IMessageSink channelSink = GetChannelSink(reqMsg);

                // Forward call to the channel.
                args[0] = reqMsg;
                args[1] = channelSink;

                InternalCrossContextDelegate xctxDel = new InternalCrossContextDelegate(SyncProcessMessageCallback);

                // Move to default context unless we are going through
                // the cross-context channel
                if (channelSink != CrossContextChannel.MessageSink)
                {
                    replyMsg = (IMessage)Thread.CurrentThread.InternalCrossContextCallback(Context.DefaultContext, xctxDel, args);
                }
                else
                {
                    replyMsg = (IMessage)xctxDel(args);
                }

                ChannelServices.NotifyProfiler(replyMsg, RemotingProfilerEvent.ClientReceive);
            }


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

            return(replyMsg);
        }
Ejemplo n.º 5
0
        public virtual IMessage     SyncProcessMessage(IMessage reqMsg)
        {
            Message.DebugOut("+++++++++++++++++++++++++ CliCtxTerminator: SyncProcessMsg");
            IMessage errMsg = ValidateMessage(reqMsg);

            if (errMsg != null)
            {
                return(errMsg);
            }

            Context ctx = Thread.CurrentContext;

            bool bHasDynamicSinks =
                ctx.NotifyDynamicSinks(reqMsg,
                                       true,  // bCliSide
                                       true,  // bStart
                                       false, // bAsync
                                       true); // bNotifyGlobals

            IMessage replyMsg;

            if (reqMsg is IConstructionCallMessage)
            {
                errMsg = ctx.NotifyActivatorProperties(
                    reqMsg,
                    false /*bServerSide*/);
                if (errMsg != null)
                {
                    return(errMsg);
                }

                replyMsg = ((IConstructionCallMessage)reqMsg).Activator.Activate(
                    (IConstructionCallMessage)reqMsg);
                BCLDebug.Assert(replyMsg is IConstructionReturnMessage, "bad ctorRetMsg");
                errMsg = ctx.NotifyActivatorProperties(
                    replyMsg,
                    false /*bServerSide*/);
                if (errMsg != null)
                {
                    return(errMsg);
                }
            }
            else
            {
                ChannelServices.NotifyProfiler(reqMsg, RemotingProfilerEvent.ClientSend);

                // Forward call to the channel.
                IMessageSink channelSink = GetChannelSink(reqMsg);
                // Move to default context unless we are going through
                // the cross-context channel
                ContextTransitionFrame frame = new ContextTransitionFrame();
                if (channelSink != CrossContextChannel.MessageSink)
                {
                    Thread.CurrentThread.EnterContext(
                        Context.DefaultContext,
                        ref frame);
                }
                replyMsg = channelSink.SyncProcessMessage(reqMsg);

                if (channelSink != CrossContextChannel.MessageSink)
                {
                    Thread.CurrentThread.ReturnToContext(ref frame);
                }

                ChannelServices.NotifyProfiler(replyMsg, RemotingProfilerEvent.ClientReceive);
            }


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

            return(replyMsg);
        }