Class Iso8211DocumentWriter
Provides methods to write (serialize) an Iso8211Document to ISO 8211 bytes.
public static class Iso8211DocumentWriter
- Inheritance
-
Iso8211DocumentWriter
- Inherited Members
Remarks
This writer is the symmetric inverse of Iso8211DocumentReader. For a document
produced by the reader from a canonically-encoded source, Read → Write yields
byte-identical output, and Read → Write → Read yields an equivalent object model.
The leader flag characters and directory entry-map sizes are preserved from each record's Leader, while the record length and base address of the field area are recomputed from the record's fields.
Methods
Write(Iso8211Document, Iso8211WriterOptions?)
Serializes an ISO 8211 document to a byte array.
public static byte[] Write(Iso8211Document document, Iso8211WriterOptions? options = null)
Parameters
documentIso8211DocumentThe document to serialize.
optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
Returns
- byte[]
The serialized ISO 8211 bytes.
Write(Stream, Iso8211Document, Iso8211WriterOptions?)
Serializes an ISO 8211 document to a stream.
public static void Write(Stream stream, Iso8211Document document, Iso8211WriterOptions? options = null)
Parameters
streamStreamThe destination stream.
documentIso8211DocumentThe document to serialize.
optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
Remarks
Every record is checked before anything is written, so a document that can't be encoded leaves the stream untouched. The output is then written a chunk of records at a time rather than built in memory first.
WriteAsync(Stream, Iso8211Document, Iso8211WriterOptions?, CancellationToken)
Asynchronously serializes an ISO 8211 document to a stream.
public static Task WriteAsync(Stream stream, Iso8211Document document, Iso8211WriterOptions? options = null, CancellationToken cancellationToken = default)
Parameters
streamStreamThe destination stream.
documentIso8211DocumentThe document to serialize.
optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
A task that represents the asynchronous write operation.
Remarks
Every record is checked before anything is written, so a document that can't be encoded leaves the stream untouched. The output is then written a chunk of records at a time rather than built in memory first.
WriteToFile(string, Iso8211Document, Iso8211WriterOptions?)
Serializes an ISO 8211 document to a file.
public static void WriteToFile(string path, Iso8211Document document, Iso8211WriterOptions? options = null)
Parameters
pathstringThe destination file path.
documentIso8211DocumentThe document to serialize.
optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
Remarks
Every record is checked before the file is opened, so a document that can't be encoded doesn't create or change the file.
WriteToFileAsync(string, Iso8211Document, Iso8211WriterOptions?, CancellationToken)
Asynchronously serializes an ISO 8211 document to a file.
public static Task WriteToFileAsync(string path, Iso8211Document document, Iso8211WriterOptions? options = null, CancellationToken cancellationToken = default)
Parameters
pathstringThe destination file path.
documentIso8211DocumentThe document to serialize.
optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
A task that represents the asynchronous write operation.
Remarks
Every record is checked before the file is opened, so a document that can't be encoded doesn't create or change the file.