예제 #1
0
        internal void BeforeSendRequest(ref ProxyRpc rpc)
        {
            int offset = this.MessageInspectorCorrelationOffset;

            try
            {
                bool      outputTiming = DS.MessageInspectorIsEnabled();
                Stopwatch sw           = null;
                if (outputTiming)
                {
                    sw = new Stopwatch();
                }

                for (int i = 0; i < this.messageInspectors.Length; i++)
                {
                    if (outputTiming)
                    {
                        sw.Restart();
                    }

                    rpc.Correlation[offset + i] = this.messageInspectors[i].BeforeSendRequest(ref rpc.Request, (IClientChannel)rpc.Channel.Proxy);
                    if (outputTiming)
                    {
                        DS.ClientMessageInspectorBeforeSend(this.messageInspectors[i].GetType(), sw.Elapsed);
                    }

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

            if (this.addTransactionFlowProperties)
            {
                SendTransaction(ref rpc);
            }
        }