Läs på engelska Redigera

Dela via


XmlDictionaryWriter.CreateBinaryWriter Method

Definition

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

Overloads

CreateBinaryWriter(Stream)

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

CreateBinaryWriter(Stream, IXmlDictionary)

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

CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession)

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

CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession, Boolean)

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

Remarks

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.

C#
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.

CreateBinaryWriter(Stream)

Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs

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

C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream);

Parameters

stream
Stream

The stream to write to.

Returns

An instance of XmlDictionaryWriter.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

CreateBinaryWriter(Stream, IXmlDictionary)

Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs

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

C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary dictionary);
C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary);

Parameters

stream
Stream

The stream to write to.

dictionary
IXmlDictionary

The XmlDictionary to use as the shared dictionary.

Returns

An instance of XmlDictionaryWriter.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession)

Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs

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

C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary dictionary, System.Xml.XmlBinaryWriterSession session);
C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session);

Parameters

stream
Stream

The stream to write to.

dictionary
IXmlDictionary

The XmlDictionary to use as the shared dictionary.

Returns

An instance of XmlDictionaryWriter.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

CreateBinaryWriter(Stream, IXmlDictionary, XmlBinaryWriterSession, Boolean)

Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs
Source:
XmlDictionaryWriter.cs

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

C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary dictionary, System.Xml.XmlBinaryWriterSession session, bool ownsStream);
C#
public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session, bool ownsStream);

Parameters

stream
Stream

The stream from which to read.

dictionary
IXmlDictionary

The XmlDictionary to use as the shared dictionary.

ownsStream
Boolean

true to indicate that the stream is closed by the writer when done; otherwise false.

Returns

An instance of XmlDictionaryWriter.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0