Export (0) Print
Expand All

XmlDictionaryWriter.CreateBinaryWriter Method

Creates an instance of XmlDictionaryWriter that writes WCF binary XML format.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Static member CreateBinaryWriter(Stream) Creates an instance of XmlDictionaryWriter that writes WCF binary XML format.
Public method Static member CreateBinaryWriter(Stream, IXmlDictionary) Creates an instance of XmlDictionaryWriter that writes WCF binary XML format.
Public method Static member CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession) Creates an instance of XmlDictionaryWriter that writes WCF binary XML format.
Public method Static member CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession, Boolean) Creates an instance of XmlDictionaryWriter that writes WCF binary XML format.
Top

The binary format only supports one text node as the attribute value and therefore buffers the values written to it to emit a single node, as shown in the following sample code.

XmlWriter binarywriter = XmlDictionaryWriter.CreateBinaryWriter(Stream.Null);
binarywriter.WriteStartAttribute("StartAttribute");
string largeStr = new string('r', 100000);
for (int i = 0; i < 10000; i++) 
{
    binarywriter.WriteValue(largeStr);
}
binarywriter.WriteEndAttribute();

In the previous sample the code buffers about 1 GB of memory, while in the other writers it writes the values as they are provided.

Show:
© 2014 Microsoft