public IMessage SyncProcessMessage(IMessage msg)
        {
            ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
            Context        context        = null;

            if (Thread.CurrentContext != serverIdentity.Context)
            {
                context = Context.SwitchToContext(serverIdentity.Context);
            }
            IMessage result;

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                result = serverIdentity.Context.GetServerContextSinkChain().SyncProcessMessage(msg);
                Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
            }
            catch (Exception e)
            {
                result = new ReturnMessage(e, (IMethodCallMessage)msg);
            }
            finally
            {
                if (context != null)
                {
                    Context.SwitchToContext(context);
                }
            }
            return(result);
        }
Exemple #2
0
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
                        #if !DISABLE_REMOTING
            ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);

            Context oldContext = null;
            if (Threading.Thread.CurrentContext != identity.Context)
            {
                oldContext = Context.SwitchToContext(identity.Context);
            }

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, true);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                if (replySink != null)
                {
                    replySink = new ContextRestoreSink(replySink, oldContext, msg);
                }

                IMessageCtrl res = identity.AsyncObjectProcessMessage(msg, replySink);

                if (replySink == null)
                {
                    Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                    Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
                }

                return(res);
            }
            catch (Exception ex)
            {
                if (replySink != null)
                {
                    replySink.SyncProcessMessage(new ReturnMessage(ex, (IMethodCallMessage)msg));
                }
                return(null);
            }
            finally
            {
                if (oldContext != null)
                {
                    Context.SwitchToContext(oldContext);
                }
            }
                        #else
            return(null);
                        #endif
        }
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
            ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
            Context        context        = null;

            if (Thread.CurrentContext != serverIdentity.Context)
            {
                context = Context.SwitchToContext(serverIdentity.Context);
            }
            IMessageCtrl result;

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, true);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                if (replySink != null)
                {
                    replySink = new CrossContextChannel.ContextRestoreSink(replySink, context, msg);
                }
                IMessageCtrl messageCtrl = serverIdentity.AsyncObjectProcessMessage(msg, replySink);
                if (replySink == null)
                {
                    Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                    Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
                }
                result = messageCtrl;
            }
            catch (Exception e)
            {
                if (replySink != null)
                {
                    replySink.SyncProcessMessage(new ReturnMessage(e, (IMethodCallMessage)msg));
                }
                result = null;
            }
            finally
            {
                if (context != null)
                {
                    Context.SwitchToContext(context);
                }
            }
            return(result);
        }
 public IMessage SyncProcessMessage(IMessage msg)
 {
     try
     {
         Context.NotifyGlobalDynamicSinks(false, msg, false, false);
         Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
         return(_next.SyncProcessMessage(msg));
     }
     catch (Exception ex)
     {
         return(new ReturnMessage(ex, (IMethodCallMessage)_call));
     }
     finally
     {
         if (_context != null)
         {
             Context.SwitchToContext(_context);
         }
     }
 }
Exemple #5
0
        public IMessage SyncProcessMessage(IMessage msg)
        {
                        #if !DISABLE_REMOTING
            ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);

            Context  oldContext = null;
            IMessage response;

            if (Threading.Thread.CurrentContext != identity.Context)
            {
                oldContext = Context.SwitchToContext(identity.Context);
            }

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);

                response = identity.Context.GetServerContextSinkChain().SyncProcessMessage(msg);

                Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
            }
            catch (Exception ex)
            {
                response = new ReturnMessage(ex, (IMethodCallMessage)msg);
            }
            finally
            {
                if (oldContext != null)
                {
                    Context.SwitchToContext(oldContext);
                }
            }

            return(response);
                        #else
            return(null);
                        #endif
        }
            public IMessage SyncProcessMessage(IMessage msg)
            {
                IMessage result;

                try
                {
                    Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                    Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
                    result = this._next.SyncProcessMessage(msg);
                }
                catch (Exception e)
                {
                    result = new ReturnMessage(e, (IMethodCallMessage)this._call);
                }
                finally
                {
                    if (this._context != null)
                    {
                        Context.SwitchToContext(this._context);
                    }
                }
                return(result);
            }