internal void WriteTo(XmlWriter writer, Func <string, string, bool> shouldSkipElement) { if (_buffer != null) { using (XmlDictionaryReader reader = _buffer.GetReader(0)) { reader.ReadStartElement(); while (reader.IsStartElement()) { if (shouldSkipElement != null && shouldSkipElement(reader.LocalName, reader.NamespaceURI)) { reader.Skip(); continue; } writer.WriteNode(reader, false); } } } else { for (int i = 0; i < Items.Count; ++i) { Items[i].WriteTo(writer); } } }
protected override void OnWriteDetail(XmlDictionaryWriter writer, EnvelopeVersion version) { using (XmlReader r = _detail.GetReader(0)) { // Start the element base.OnWriteStartDetail(writer, version); // Copy the attributes while (r.MoveToNextAttribute()) { if (ShouldWriteDetailAttribute(version, r.Prefix, r.LocalName, r.Value)) { writer.WriteAttributeString(r.Prefix, r.LocalName, r.NamespaceURI, r.Value); } } r.MoveToElement(); r.Read(); // Copy the contents while (r.NodeType != XmlNodeType.EndElement) { writer.WriteNode(r, false); } // End the element writer.WriteEndElement(); } }
private XmlDictionaryReader CreateFullBodyReaderFromBufferedState() { if (_messageBuffer != null) { XmlDictionaryReader reader = _messageBuffer.GetReader(0); MoveToBody(reader); return(reader); } else { return(((BufferedMessage)InnerMessage).GetBufferedReaderAtBody()); } }
public SecurityVerifiedMessage(Message messageToProcess, ReceiveSecurityHeader securityHeader) : base(messageToProcess) { ReceivedSecurityHeader = securityHeader; if (securityHeader.RequireMessageProtection) { XmlDictionaryReader messageReader; BufferedMessage bufferedMessage = InnerMessage as BufferedMessage; if (bufferedMessage != null && Headers.ContainsOnlyBufferedMessageHeaders) { messageReader = bufferedMessage.GetMessageReader(); } else { _messageBuffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter writer = _messageBuffer.OpenSection(ReceivedSecurityHeader.ReaderQuotas); InnerMessage.WriteMessage(writer); _messageBuffer.CloseSection(); _messageBuffer.Close(); messageReader = _messageBuffer.GetReader(0); } MoveToSecurityHeader(messageReader, securityHeader.HeaderIndex, true); _cachedReaderAtSecurityHeader = messageReader; _state = BodyState.Buffered; } else { _envelopeAttributes = XmlAttributeHolder.emptyArray; _headerAttributes = XmlAttributeHolder.emptyArray; _bodyAttributes = XmlAttributeHolder.emptyArray; _canDelegateCreateBufferedCopyToInnerMessage = true; } }
protected virtual XmlDictionaryReader OnGetReaderAtBodyContents() { XmlBuffer buffer = new XmlBuffer(0x7fffffff); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); if (this.Version.Envelope != EnvelopeVersion.None) { this.OnWriteStartEnvelope(writer); this.OnWriteStartBody(writer); } this.OnWriteBodyContents(writer); if (this.Version.Envelope != EnvelopeVersion.None) { writer.WriteEndElement(); writer.WriteEndElement(); } buffer.CloseSection(); buffer.Close(); XmlDictionaryReader reader = buffer.GetReader(0); if (this.Version.Envelope != EnvelopeVersion.None) { reader.ReadStartElement(); reader.ReadStartElement(); } reader.MoveToContent(); return(reader); }
public XmlReader GetReaderAtElementExtensions() { XmlBuffer extensionsBuffer = GetOrCreateBufferOverExtensions(); XmlReader reader = extensionsBuffer.GetReader(0); reader.ReadStartElement(); return(reader); }
public async Task <XmlReader> GetReaderAtElementExtensionsAsync() { XmlBuffer extensionsBuffer = await GetOrCreateBufferOverExtensions(); XmlReader reader = extensionsBuffer.GetReader(0); reader.ReadStartElement(); return(reader); }
public virtual XmlDictionaryReader GetAddressHeaderReader() { XmlBuffer buffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); WriteAddressHeader(writer); buffer.CloseSection(); buffer.Close(); return(buffer.GetReader(0)); }
internal async Task WriteToAsync(XmlWriter writer) { if (_buffer != null) { using (XmlDictionaryReader reader = _buffer.GetReader(0)) { reader.ReadStartElement(); while (reader.IsStartElement()) { await writer.WriteNodeAsync(reader, false); } } } else { for (int i = 0; i < Items.Count; ++i) { await Items[i].WriteToAsync(writer); } } }
private XmlDictionaryReader GetComparableReader() { XmlBuffer buffer = new XmlBuffer(0x7fffffff); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); ParameterHeader.WriteStartHeader(writer, this, AddressingVersion.WSAddressingAugust2004); ParameterHeader.WriteHeaderContents(writer, this); writer.WriteEndElement(); buffer.CloseSection(); buffer.Close(); return(buffer.GetReader(0)); }
internal void WriteTo(XmlWriter writer) { if (_buffer != null) { using (XmlDictionaryReader reader = _buffer.GetReader(0)) { reader.ReadStartElement(); while (reader.IsStartElement()) { writer.WriteNode(reader, false); } } } else { for (int i = 0; i < this.Items.Count; ++i) { this.Items[i].WriteTo(writer); } } }
protected virtual XmlDictionaryReader OnGetReaderAtDetailContents() { XmlBuffer detailBuffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter writer = detailBuffer.OpenSection(XmlDictionaryReaderQuotas.Max); OnWriteDetail(writer, EnvelopeVersion.Soap12); // Wrap in soap 1.2 by default detailBuffer.CloseSection(); detailBuffer.Close(); XmlDictionaryReader reader = detailBuffer.GetReader(0); reader.Read(); // Skip the detail element return(reader); }
protected virtual XmlDictionaryReader OnGetReaderAtDetailContents() { XmlBuffer buffer = new XmlBuffer(0x7fffffff); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); this.OnWriteDetail(writer, EnvelopeVersion.Soap12); buffer.CloseSection(); buffer.Close(); XmlDictionaryReader reader = buffer.GetReader(0); reader.Read(); return(reader); }
protected override void OnWriteBodyContents(XmlDictionaryWriter writer) { XmlDictionaryReader reader = _buffer.GetReader(0); using (reader) { reader.ReadStartElement(); while (reader.NodeType != XmlNodeType.EndElement) { writer.WriteNode(reader, false); } reader.ReadEndElement(); } }
XmlDictionaryReader GetComparableReader() { XmlBuffer buffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); // WSAddressingAugust2004 does not write the IsReferenceParameter attribute, // and that's good for a consistent comparable form ParameterHeader.WriteStartHeader(writer, this, AddressingVersion.WSAddressingAugust2004); ParameterHeader.WriteHeaderContents(writer, this); writer.WriteEndElement(); buffer.CloseSection(); buffer.Close(); return(buffer.GetReader(0)); }
public override XmlDictionaryReader GetHeaderReader() { XmlDictionaryReader reader = buffer.GetReader(bufferIndex); // See if we need to move past the enclosing envelope/header if (streamed) { reader.MoveToContent(); reader.Read(); // Envelope reader.Read(); // Header reader.MoveToContent(); } return(reader); }
private bool InferHasDetail(XmlBuffer detail) { bool flag = false; if (detail != null) { XmlDictionaryReader reader = detail.GetReader(0); if (!reader.IsEmptyElement && reader.Read()) { flag = reader.MoveToContent() != XmlNodeType.EndElement; } reader.Close(); } return(flag); }
bool InferHasDetail(XmlBuffer detail) { bool hasDetail = false; if (detail != null) { XmlDictionaryReader reader = detail.GetReader(0); if (!reader.IsEmptyElement && reader.Read()) // check if the detail element contains data { hasDetail = (reader.MoveToContent() != XmlNodeType.EndElement); } reader.Dispose(); } return(hasDetail); }
public override Message CreateMessage() { if (closed) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateBufferDisposedException()); } Message msg; if (isNullMessage) { msg = new NullMessage(); } else { msg = Message.CreateMessage(msgBuffer.GetReader(0), int.MaxValue, version); } lock (ThisLock) { msg.Properties.CopyProperties(properties); } for (int i = 0; i < understoodHeaders.Length; ++i) { if (understoodHeaders[i]) { msg.Headers.AddUnderstood(i); } } if (to != null) { msg.Headers.To = to; } if (action != null) { msg.Headers.Action = action; } return(msg); }
internal virtual XmlDictionaryReader GetReaderAtHeader() { XmlBuffer buffer = new XmlBuffer(0x7fffffff); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); this.WriteStartEnvelope(writer); MessageHeaders headers = this.Headers; for (int i = 0; i < headers.Count; i++) { headers.WriteHeader(i, writer); } writer.WriteEndElement(); writer.WriteEndElement(); buffer.CloseSection(); buffer.Close(); XmlDictionaryReader reader = buffer.GetReader(0); reader.ReadStartElement(); reader.MoveToStartElement(); return(reader); }
public void WriteBodyToSignThenEncrypt(Stream canonicalStream, EncryptedData encryptedData, SymmetricAlgorithm algorithm) { XmlBuffer buffer = new XmlBuffer(0x7fffffff); XmlDictionaryWriter writer = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); this.WriteBodyToSignThenEncryptWithFragments(canonicalStream, false, null, encryptedData, algorithm, writer); ((IFragmentCapableXmlDictionaryWriter)writer).WriteFragment(this.startBodyFragment.GetBuffer(), 0, (int)this.startBodyFragment.Length); ((IFragmentCapableXmlDictionaryWriter)writer).WriteFragment(this.endBodyFragment.GetBuffer(), 0, (int)this.endBodyFragment.Length); buffer.CloseSection(); buffer.Close(); this.startBodyFragment = null; this.endBodyFragment = null; XmlDictionaryReader reader = buffer.GetReader(0); reader.MoveToContent(); this.bodyPrefix = reader.Prefix; if (reader.HasAttributes) { this.bodyAttributes = System.IdentityModel.XmlAttributeHolder.ReadAttributes(reader); } reader.Close(); }
public void WriteBodyToSignThenEncrypt(Stream canonicalStream, EncryptedData encryptedData, SymmetricAlgorithm algorithm) { XmlBuffer buffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter fragmentingWriter = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); WriteBodyToSignThenEncryptWithFragments(canonicalStream, false, null, encryptedData, algorithm, fragmentingWriter); ((IFragmentCapableXmlDictionaryWriter)fragmentingWriter).WriteFragment(_startBodyFragment.GetBuffer(), 0, (int)_startBodyFragment.Length); ((IFragmentCapableXmlDictionaryWriter)fragmentingWriter).WriteFragment(_endBodyFragment.GetBuffer(), 0, (int)_endBodyFragment.Length); buffer.CloseSection(); buffer.Close(); _startBodyFragment = null; _endBodyFragment = null; XmlDictionaryReader reader = buffer.GetReader(0); reader.MoveToContent(); _bodyPrefix = reader.Prefix; if (reader.HasAttributes) { _bodyAttributes = XmlAttributeHolder.ReadAttributes(reader); } reader.Close(); }
public SecurityVerifiedMessage(Message messageToProcess, ReceiveSecurityHeader securityHeader) : base(messageToProcess) { ReceivedSecurityHeader = securityHeader; if (securityHeader.RequireMessageProtection) { XmlDictionaryReader messageReader; if (InnerMessage is BufferedMessage bufferedMessage && Headers.ContainsOnlyBufferedMessageHeaders) { messageReader = bufferedMessage.GetMessageReader(); } else { _messageBuffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter writer = _messageBuffer.OpenSection(ReceivedSecurityHeader.ReaderQuotas); InnerMessage.WriteMessage(writer); _messageBuffer.CloseSection(); _messageBuffer.Close(); messageReader = _messageBuffer.GetReader(0); } MoveToSecurityHeader(messageReader, securityHeader.HeaderIndex, true); _cachedReaderAtSecurityHeader = messageReader; _state = BodyState.Buffered; }
public async Task <XmlDictionaryReader> GetReaderAtContentAsync() { await EnsureContentBufferAsync().ConfigureAwait(false); return(_contentBuffer.GetReader(0)); }
public void WriteBodyToSignThenEncrypt(Stream canonicalStream, EncryptedData encryptedData, SymmetricAlgorithm algorithm) { XmlBuffer buffer = new XmlBuffer(int.MaxValue); XmlDictionaryWriter fragmentingWriter = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); WriteBodyToSignThenEncryptWithFragments(canonicalStream, false, null, encryptedData, algorithm, fragmentingWriter); ((IFragmentCapableXmlDictionaryWriter)fragmentingWriter).WriteFragment(this.startBodyFragment.GetBuffer(), 0, (int)this.startBodyFragment.Length); ((IFragmentCapableXmlDictionaryWriter)fragmentingWriter).WriteFragment(this.endBodyFragment.GetBuffer(), 0, (int)this.endBodyFragment.Length); buffer.CloseSection(); buffer.Close(); this.startBodyFragment = null; this.endBodyFragment = null; XmlDictionaryReader reader = buffer.GetReader(0); reader.MoveToContent(); this.bodyPrefix = reader.Prefix; if (reader.HasAttributes) { this.bodyAttributes = XmlAttributeHolder.ReadAttributes(reader); } reader.Close(); }
public async Task <XmlDictionaryReader> GetReaderAtContent() { await EnsureContentBufferAsync(); return(_contentBuffer.GetReader(0)); }
public override XmlDictionaryReader GetAddressHeaderReader() { return(buffer.GetReader(0)); }
public XmlDictionaryReader GetReaderAtContent() { EnsureContentBuffer(); return(_contentBuffer.GetReader(0)); }