System.Runtime.Serialization 4.0.0.0

When writing an outgoing message containing a streamed body to an XML writer, the will use a sequence of calls similar to the following in its 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.

For this purpose, the interface is used. The interface has a method that returns the stream to be written. The correct way to write out a streamed message body in is as follows:

Write any necessary information preceding the stream (For example, the opening XML tag)

Call the WriteValue overload on the 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 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 later, when it is ready to write the appropriate part of the message.

Represents an interface that can be implemented by classes providing streams.

- Method
  4.0.0.0
  System.IO.Stream

  This method can be used to return the stream to be written.

  Gets a stream.

  A object.

- Method
  4.0.0.0
  System.Void `` To be added.

  Releases a stream to output.

  The stream being released.