コード例 #1
0
        void DeserializeInputs(ref MessageRpc rpc)
        {
            bool success = false;

            try
            {
                try
                {
                    rpc.InputParameters = this.Invoker.AllocateInputs();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
                try
                {
                    // If the field is true, then this operation is to be invoked at the time the service
                    // channel is opened. The incoming message is created at ChannelHandler level with no
                    // content, so we don't need to deserialize the message.
                    if (!this.isSessionOpenNotificationEnabled)
                    {
                        if (this.deserializeRequest)
                        {
                            if (TD.DispatchFormatterDeserializeRequestStartIsEnabled())
                            {
                                TD.DispatchFormatterDeserializeRequestStart(rpc.EventTraceActivity);
                            }

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

                            this.Formatter.DeserializeRequest(rpc.Request, rpc.InputParameters);

                            if (outputTiming)
                            {
                                DS.DispatchMessageFormatterDeserialize(this.Formatter.GetType(), sw.Elapsed);
                            }

                            if (TD.DispatchFormatterDeserializeRequestStopIsEnabled())
                            {
                                TD.DispatchFormatterDeserializeRequestStop(rpc.EventTraceActivity);
                            }
                        }
                        else
                        {
                            rpc.InputParameters[0] = rpc.Request;
                        }
                    }

                    success = true;
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
            }
            finally
            {
                rpc.DidDeserializeRequestBody = (rpc.Request.State != MessageState.Created);

                if (!success && MessageLogger.LoggingEnabled)
                {
                    MessageLogger.LogMessage(ref rpc.Request, MessageLoggingSource.Malformed);
                }
            }
        }