예제 #1
0
        internal void AfterReply(ref ProxyRpc rpc)
        {
            if (!this.isOneWay)
            {
                Message reply = rpc.Reply;

                if (this.deserializeReply)
                {
                    if (TD.ClientFormatterDeserializeReplyStartIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity);
                    }

                    bool      outputTiming = DS.MessageFormatterIsEnabled();
                    Stopwatch sw           = null;
                    if (outputTiming)
                    {
                        sw = Stopwatch.StartNew();
                    }

                    rpc.ReturnValue = this.formatter.DeserializeReply(reply, rpc.OutputParameters);

                    if (outputTiming)
                    {
                        DS.ClientMessageFormatterDeserialize(this.formatter.GetType(), sw.Elapsed);
                    }

                    if (TD.ClientFormatterDeserializeReplyStopIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity);
                    }
                }
                else
                {
                    rpc.ReturnValue = reply;
                }

                int offset = this.parent.ParameterInspectorCorrelationOffset;
                try
                {
                    bool      outputTiming = DS.ParameterInspectorIsEnabled();
                    Stopwatch sw           = null;
                    if (outputTiming)
                    {
                        sw = new Stopwatch();
                    }

                    for (int i = parameterInspectors.Length - 1; i >= 0; i--)
                    {
                        if (outputTiming)
                        {
                            sw.Restart();
                        }

                        this.parameterInspectors[i].AfterCall(this.name,
                                                              rpc.OutputParameters,
                                                              rpc.ReturnValue,
                                                              rpc.Correlation[offset + i]);
                        if (outputTiming)
                        {
                            DS.ParameterInspectorAfter(this.parameterInspectors[i].GetType(), sw.Elapsed);
                        }

                        if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled())
                        {
                            TD.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, this.parameterInspectors[i].GetType().FullName);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }

                if (parent.ValidateMustUnderstand)
                {
                    Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood();
                    if (headersNotUnderstood != null && headersNotUnderstood.Count > 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.GetString(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace)));
                    }
                }
            }
        }