Represents an interface that can be implemented by classes providing streams.
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
When writing an outgoing message containing a streamed body to an XML writer, the Message will use a sequence of calls similar to the following in its OnWriteBodyContents(XmlDictionaryWriter) implementation:
Write any necessary information preceding the stream (For example, the opening XML tag).
Write the stream.
Write any information following the stream (For example, the closing XML tag).
This works well with encodings that are similar to the textual XML encoding. However, there are some encodings that do not place XML infoset information (For example, tags for starting and ending XML elements) together with the data contained within elements. For example, in the MTOM encoding, the message is split into multiple parts. One part contains the XML infoset, which may contain references to other parts for actual element contents. Since the XML infoset will normally be small compared to the streamed contents, it makes sense to buffer the infoset, write it out, and then write the contents in a streamed way. This means that by the time the closing element tag is written, we should not have written out the stream yet.
Write any necessary information preceding the stream (For example, the opening XML tag)
Call the WriteValue overload on the XmlDictionaryWriter that takes an , with an IStreamProvider implementation that returns the stream to be written.
Write any information following the stream (For example, the closing XML tag)
With this approach, the XML writer has a choice of when to call GetStream() and write out the streamed data. For example, the textual and binary XML writers will call it immediately and write out the streamed contents in between the start and end tags. The MTOM writer may decide to call GetStream() later, when it is ready to write the appropriate part of the message.
Available since 3.0
Available since 4.0