public PatternMessage(IBufferedMessageData messageData, MessageVersion messageVersion, KeyValuePair <string, object>[] properties, MessageHeaders headers) { this.messageData = messageData; this.messageData.Open(); this.recycledMessageState = this.messageData.TakeMessageState(); if (this.recycledMessageState == null) { this.recycledMessageState = new System.ServiceModel.Channels.RecycledMessageState(); } this.properties = this.recycledMessageState.TakeProperties(); if (this.properties == null) { this.properties = new MessageProperties(); } if (properties != null) { this.properties.CopyProperties(properties); } this.headers = this.recycledMessageState.TakeHeaders(); if (this.headers == null) { this.headers = new MessageHeaders(messageVersion); } if (headers != null) { this.headers.CopyHeadersFrom(headers); } XmlDictionaryReader messageReader = messageData.GetMessageReader(); messageReader.ReadStartElement(); ReceivedMessage.VerifyStartBody(messageReader, messageVersion.Envelope); base.ReadStartBody(messageReader); this.reader = messageReader; }
public PatternMessage(IBufferedMessageData messageData, MessageVersion messageVersion) { this.messageData = messageData; this.recycledMessageState = messageData.TakeMessageState(); if (this.recycledMessageState == null) { this.recycledMessageState = new System.ServiceModel.Channels.RecycledMessageState(); } this.properties = this.recycledMessageState.TakeProperties(); if (this.properties == null) { this.properties = new MessageProperties(); } this.headers = this.recycledMessageState.TakeHeaders(); if (this.headers == null) { this.headers = new MessageHeaders(messageVersion); } else { this.headers.Init(messageVersion); } XmlDictionaryReader messageReader = messageData.GetMessageReader(); messageReader.ReadStartElement(); ReceivedMessage.VerifyStartBody(messageReader, messageVersion.Envelope); base.ReadStartBody(messageReader); this.reader = messageReader; }
public StreamedMessage(XmlDictionaryReader reader, int maxSizeOfHeaders, MessageVersion desiredVersion) { if (reader.NodeType != XmlNodeType.Element) { reader.MoveToContent(); } if (desiredVersion.Envelope == EnvelopeVersion.None) { this.reader = reader; this.headerAttributes = XmlAttributeHolder.emptyArray; this.headers = new MessageHeaders(desiredVersion); } else { this.envelopeAttributes = XmlAttributeHolder.ReadAttributes(reader, ref maxSizeOfHeaders); this.envelopePrefix = reader.Prefix; EnvelopeVersion envelopeVersion = ReceivedMessage.ReadStartEnvelope(reader); if (desiredVersion.Envelope != envelopeVersion) { Exception innerException = new ArgumentException(System.ServiceModel.SR.GetString("EncoderEnvelopeVersionMismatch", new object[] { envelopeVersion, desiredVersion.Envelope }), "reader"); throw TraceUtility.ThrowHelperError(new CommunicationException(innerException.Message, innerException), this); } if (ReceivedMessage.HasHeaderElement(reader, envelopeVersion)) { this.headerPrefix = reader.Prefix; this.headerAttributes = XmlAttributeHolder.ReadAttributes(reader, ref maxSizeOfHeaders); this.headers = new MessageHeaders(desiredVersion, reader, this.envelopeAttributes, this.headerAttributes, ref maxSizeOfHeaders); } else { this.headerAttributes = XmlAttributeHolder.emptyArray; this.headers = new MessageHeaders(desiredVersion); } if (reader.NodeType != XmlNodeType.Element) { reader.MoveToContent(); } this.bodyPrefix = reader.Prefix; ReceivedMessage.VerifyStartBody(reader, envelopeVersion); this.bodyAttributes = XmlAttributeHolder.ReadAttributes(reader, ref maxSizeOfHeaders); if (base.ReadStartBody(reader)) { this.reader = reader; } else { this.quotas = new XmlDictionaryReaderQuotas(); reader.Quotas.CopyTo(this.quotas); reader.Close(); } } }
public BufferedMessage(IBufferedMessageData messageData, System.ServiceModel.Channels.RecycledMessageState recycledMessageState, bool[] understoodHeaders, bool understoodHeadersModified) { bool flag = true; try { this.recycledMessageState = recycledMessageState; this.messageData = messageData; this.properties = recycledMessageState.TakeProperties(); if (this.properties == null) { this.properties = new MessageProperties(); } XmlDictionaryReader messageReader = messageData.GetMessageReader(); MessageVersion messageVersion = messageData.MessageEncoder.MessageVersion; if (messageVersion.Envelope == EnvelopeVersion.None) { this.reader = messageReader; this.headers = new MessageHeaders(messageVersion); } else { EnvelopeVersion envelopeVersion = ReceivedMessage.ReadStartEnvelope(messageReader); if (messageVersion.Envelope != envelopeVersion) { Exception innerException = new ArgumentException(System.ServiceModel.SR.GetString("EncoderEnvelopeVersionMismatch", new object[] { envelopeVersion, messageVersion.Envelope }), "reader"); throw TraceUtility.ThrowHelperError(new CommunicationException(innerException.Message, innerException), this); } if (ReceivedMessage.HasHeaderElement(messageReader, envelopeVersion)) { this.headers = recycledMessageState.TakeHeaders(); if (this.headers == null) { this.headers = new MessageHeaders(messageVersion, messageReader, messageData, recycledMessageState, understoodHeaders, understoodHeadersModified); } else { this.headers.Init(messageVersion, messageReader, messageData, recycledMessageState, understoodHeaders, understoodHeadersModified); } } else { this.headers = new MessageHeaders(messageVersion); } ReceivedMessage.VerifyStartBody(messageReader, envelopeVersion); int maxSizeOfHeaders = 0x7fffffff; this.bodyAttributes = XmlAttributeHolder.ReadAttributes(messageReader, ref maxSizeOfHeaders); if (maxSizeOfHeaders < 0x7fffefff) { this.bodyAttributes = null; } if (base.ReadStartBody(messageReader)) { this.reader = messageReader; } else { messageReader.Close(); } } flag = false; } finally { if (flag && MessageLogger.LoggingEnabled) { MessageLogger.LogMessage(messageData.Buffer, MessageLoggingSource.Malformed); } } }