internal void BeforeRequest(ref ProxyRpc rpc) { int offset = this.parent.ParameterInspectorCorrelationOffset; try { bool outputTiming = DS.ParameterInspectorIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = new Stopwatch(); } for (int i = 0; i < parameterInspectors.Length; i++) { if (outputTiming) { sw.Restart(); } rpc.Correlation[offset + i] = this.parameterInspectors[i].BeforeCall(this.name, rpc.InputParameters); if (outputTiming) { DS.ParameterInspectorBefore(this.parameterInspectors[i].GetType(), sw.Elapsed); } if (TD.ClientParameterInspectorBeforeCallInvokedIsEnabled()) { TD.ClientParameterInspectorBeforeCallInvoked(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 (this.serializeRequest) { if (TD.ClientFormatterSerializeRequestStartIsEnabled()) { TD.ClientFormatterSerializeRequestStart(rpc.EventTraceActivity); } bool outputTiming = DS.MessageFormatterIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = Stopwatch.StartNew(); } rpc.Request = this.formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters); if (outputTiming) { DS.ClientMessageFormatterSerialize(this.formatter.GetType(), sw.Elapsed); } if (TD.ClientFormatterSerializeRequestStopIsEnabled()) { TD.ClientFormatterSerializeRequestStop(rpc.EventTraceActivity); } } else { if (rpc.InputParameters[0] == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxProxyRuntimeMessageCannotBeNull, this.name))); } rpc.Request = (Message)rpc.InputParameters[0]; if (!IsValidAction(rpc.Request, Action)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInvalidRequestAction, this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action))); } } }