Table of Contents

Class Iso8211FieldBuilder

Namespace
EncDotNet.Iso8211
Assembly
EncDotNet.Iso8211.dll

Builds an Iso8211Field by encoding subfield values according to a field definition.

public sealed class Iso8211FieldBuilder
Inheritance
Iso8211FieldBuilder
Inherited Members

Remarks

The builder encodes subfields in declaration order and, when the parent field defines a repeating subfield group, wraps back to the start of the group — mirroring the parsing behaviour of Iso8211FieldReader. Unit terminators (0x1F) are inserted after variable-length subfields when another subfield follows; the trailing field terminator (0x1E) is added by EncDotNet.Iso8211.Iso8211RecordWriter when the record is written.

Constructors

Iso8211FieldBuilder(Iso8211FieldDefinition, Iso8211WriterOptions?)

Initializes a new instance of the Iso8211FieldBuilder class from a field definition.

public Iso8211FieldBuilder(Iso8211FieldDefinition definition, Iso8211WriterOptions? options = null)

Parameters

definition Iso8211FieldDefinition

The field definition describing the field tag and subfield formats.

options Iso8211WriterOptions

Optional writer options. Defaults to Default.

Iso8211FieldBuilder(string, IEnumerable<Iso8211SubfieldFormat>, int, Iso8211WriterOptions?)

Initializes a new instance of the Iso8211FieldBuilder class from explicit subfield formats.

public Iso8211FieldBuilder(string tag, IEnumerable<Iso8211SubfieldFormat> formats, int repeatingStartIndex = -1, Iso8211WriterOptions? options = null)

Parameters

tag string

The field tag.

formats IEnumerable<Iso8211SubfieldFormat>

The subfield formats, in declaration order.

repeatingStartIndex int

The index at which the repeating subfield group begins, or -1 for no repeating group.

options Iso8211WriterOptions

Optional writer options. Defaults to Default.

Properties

Tag

Gets the field tag being built.

public string Tag { get; }

Property Value

string

Methods

AddRaw(byte[], bool)

Appends raw, pre-encoded bytes to the field data as a single variable-length segment.

public Iso8211FieldBuilder AddRaw(byte[] bytes, bool isVariableLength = true)

Parameters

bytes byte[]

The raw bytes to append.

isVariableLength bool

Whether the appended segment should be followed by a unit terminator when another segment follows. Defaults to true.

Returns

Iso8211FieldBuilder

This builder, for chaining.

AddSubfield(object?)

Encodes a single subfield value using the next subfield format in sequence.

public Iso8211FieldBuilder AddSubfield(object? value)

Parameters

value object

The value to encode.

Returns

Iso8211FieldBuilder

This builder, for chaining.

Exceptions

InvalidOperationException

Thrown when there are no more subfield formats to consume and the field has no repeating group.

AddSubfields(params object?[])

Encodes multiple subfield values in sequence.

public Iso8211FieldBuilder AddSubfields(params object?[] values)

Parameters

values object[]

The values to encode, in declaration order.

Returns

Iso8211FieldBuilder

This builder, for chaining.

Build()

Builds the Iso8211Field with the encoded subfield data.

public Iso8211Field Build()

Returns

Iso8211Field

The built field. The data excludes the trailing field terminator.