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 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); } } }
public BufferedMessage(IBufferedMessageData messageData, System.ServiceModel.Channels.RecycledMessageState recycledMessageState) : this(messageData, recycledMessageState, null, false) { }
protected override void OnClose() { Exception exception = null; try { base.OnClose(); } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } exception = exception2; } try { this.properties.Dispose(); } catch (Exception exception3) { if (Fx.IsFatal(exception3)) { throw; } if (exception == null) { exception = exception3; } } try { if (this.reader != null) { this.reader.Close(); } } catch (Exception exception4) { if (Fx.IsFatal(exception4)) { throw; } if (exception == null) { exception = exception4; } } try { this.recycledMessageState.ReturnHeaders(this.headers); this.recycledMessageState.ReturnProperties(this.properties); this.messageData.ReturnMessageState(this.recycledMessageState); this.recycledMessageState = null; this.messageData.Close(); this.messageData = null; } catch (Exception exception5) { if (Fx.IsFatal(exception5)) { throw; } if (exception == null) { exception = exception5; } } if (exception != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } }
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); } } }
protected override void OnClose() { Exception exception = null; try { base.OnClose(); } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } exception = exception2; } try { this.properties.Dispose(); } catch (Exception exception3) { if (Fx.IsFatal(exception3)) { throw; } if (exception == null) { exception = exception3; } } try { if (this.reader != null) { this.reader.Close(); } } catch (Exception exception4) { if (Fx.IsFatal(exception4)) { throw; } if (exception == null) { exception = exception4; } } try { this.recycledMessageState.ReturnHeaders(this.headers); this.recycledMessageState.ReturnProperties(this.properties); this.messageData.ReturnMessageState(this.recycledMessageState); this.recycledMessageState = null; this.messageData.Close(); this.messageData = null; } catch (Exception exception5) { if (Fx.IsFatal(exception5)) { throw; } if (exception == null) { exception = exception5; } } if (exception != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception); } }