Class Iso8211FieldBuilder
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
definitionIso8211FieldDefinitionThe field definition describing the field tag and subfield formats.
optionsIso8211WriterOptionsOptional 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
tagstringThe field tag.
formatsIEnumerable<Iso8211SubfieldFormat>The subfield formats, in declaration order.
repeatingStartIndexintThe index at which the repeating subfield group begins, or
-1for no repeating group.optionsIso8211WriterOptionsOptional writer options. Defaults to Default.
Properties
Tag
Gets the field tag being built.
public string Tag { get; }
Property Value
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
bytesbyte[]The raw bytes to append.
isVariableLengthboolWhether 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
valueobjectThe 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
valuesobject[]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.