Exemplo n.º 1
0
        //实现IMessageSink的接口方法,当消息传递的时候,该方法被调用
        //性能呢?
        public IMessage SyncProcessMessage(IMessage msg)
        {
            //拦截消息,做前处理
            Preprocess(msg);    //参数Log、校验

            var retMsg = _ifTraceCostTime ? Process(msg) : NextSink.SyncProcessMessage(msg);

            //调用返回时进行拦截,并进行后处理
            Postprocess(msg, retMsg); //返回Log(返回值、异常)

            return(retMsg);
        }
Exemplo n.º 2
0
        public IMessage SyncProcessMessage(IMessage msg)
        {
            //拦截消息,做前处理
            Preprocess(msg);

            var retMsg = _ifTraceCostTime ? Process(msg) : NextSink.SyncProcessMessage(msg);

            //调用返回时进行拦截,并进行后处理
            Postprocess(retMsg);

            return(retMsg);
        }
 /// <summary>
 /// Process asynchronous messages through the sink chain. Mocking can be applied here.
 /// </summary>
 public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
 {
     if (RecorderManager.IsPlaying)
     {
         MockableCall     call    = new MockableCall(null, (IMethodCallMessage)msg);
         AsyncCallHandler handler = new AsyncCallHandler(replySink, call);
         RecorderManager.RecordCall(call);
     }
     else if (RecorderManager.IsRecording)
     {
     }
     else
     {
         return(NextSink.AsyncProcessMessage(msg, replySink));
     }
     return(nextMessageSink.AsyncProcessMessage(
                msg,
                new AsyncCallHandler(
                    replySink,
                    new MockableCall(null, (IMethodCallMessage)msg)
                    )
                ));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Asynchronously processes the given message.
 /// </summary>
 /// <param name="msg">The message to process.</param>
 /// <param name="replySink">The reply sink for the reply message.</param>
 /// <returns>
 /// Returns an <see cref="T:System.Runtime.Remoting.Messaging.IMessageCtrl" /> interface that provides a way to control asynchronous messages after they have been dispatched.
 /// </returns>
 public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
 {
     return(NextSink.AsyncProcessMessage(msg, replySink));
 }