public override Message ReadMessage(Stream stream, int maxSizeOfHeaders, string contentType)
            {
                if (stream == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("stream"));
                }

                if (WebTD.JsonMessageDecodingStartIsEnabled())
                {
                    WebTD.JsonMessageDecodingStart();
                }

                XmlReader reader  = TakeStreamedReader(stream, TextMessageEncoderFactory.GetEncodingFromContentType(contentType, JsonMessageEncoderFactory.ApplicationJsonContentEncoding));
                Message   message = Message.CreateMessage(reader, maxSizeOfHeaders, MessageVersion.None);

                message.Properties.Encoder = this;

                if (SMTD.StreamedMessageReadByEncoderIsEnabled())
                {
                    SMTD.StreamedMessageReadByEncoder(EventTraceActivityHelper.TryExtractActivity(message, true));
                }

                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive);
                }
                return(message);
            }
            public override Message ReadMessage(ArraySegment <byte> buffer, BufferManager bufferManager, string contentType)
            {
                if (bufferManager == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bufferManager"));
                }

                if (WebTD.JsonMessageDecodingStartIsEnabled())
                {
                    WebTD.JsonMessageDecodingStart();
                }

                Message message;

                JsonBufferedMessageData messageData = TakeBufferedReader();

                messageData.Encoding = TextMessageEncoderFactory.GetEncodingFromContentType(contentType, JsonMessageEncoderFactory.ApplicationJsonContentEncoding);
                messageData.Open(buffer, bufferManager);
                RecycledMessageState messageState = messageData.TakeMessageState();

                if (messageState == null)
                {
                    messageState = new RecycledMessageState();
                }
                message = new BufferedMessage(messageData, messageState);

                message.Properties.Encoder = this;

                if (SMTD.MessageReadByEncoderIsEnabled() && buffer != null)
                {
                    SMTD.MessageReadByEncoder(
                        EventTraceActivityHelper.TryExtractActivity(message, true),
                        buffer.Count,
                        this);
                }

                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive);
                }

                return(message);
            }