Compartir a través de


XmlDictionaryWriter.CreateBinaryWriter Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Include Protected Members
Include Inherited Members

Include Silverlight Members
Include Silverlight for Windows Phone Members
Include XNA Framework Members

Creates an instance of XmlDictionaryWriter that writes Silverlight 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.

Overload List

  Name Description
Public methodStatic memberSupported by Silverlight for Windows Phone CreateBinaryWriter(Stream) Creates an instance of XmlDictionaryWriter that writes Silverlight binary XML format.
Public methodStatic memberSupported by Silverlight for Windows Phone CreateBinaryWriter(Stream, IXmlDictionary) Creates an instance of XmlDictionaryWriter that writes Silverlight binary XML format.
Public methodStatic memberSupported by Silverlight for Windows Phone CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession) Creates an instance of XmlDictionaryWriter that writes Silverlight binary XML format.
Public methodStatic memberSupported by Silverlight for Windows Phone CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession, Boolean) Creates an instance of XmlDictionaryWriter that writes Silverlight binary XML format.

Top

Remarks

The binary format supports only 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, whereas in the other writers it writes the values as they are provided.