Class FixedWidthBinaryFieldAttribute
- Namespace
- Wolfgang.Etl.FixedWidth.Attributes
- Assembly
- Wolfgang.Etl.FixedWidth.dll
Marks a property as a field in a fixed-length binary record (#21) — the mainframe
counterpart to FixedWidthFieldAttribute. Widths are in bytes (not
characters), the byte offset is summed from the ByteLength of preceding columns in
Index order, and Type selects how the bytes are decoded (text,
COMP-3 packed decimal, or COMP binary integer). Read a record with
FixedWidthBinaryExtractor<TRecord>.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class FixedWidthBinaryFieldAttribute : Attribute
- Inheritance
-
FixedWidthBinaryFieldAttribute
- Inherited Members
Examples
public class AccountRecord
{
[FixedWidthBinaryField(0, 8, BinaryFieldType.Text)]
public string AccountId { get; set; } = string.Empty;
[FixedWidthBinaryField(1, 4, BinaryFieldType.Binary)]
public int TransactionCount { get; set; }
[FixedWidthBinaryField(2, 5, BinaryFieldType.PackedDecimal, Scale = 2)]
public decimal Balance { get; set; } // PIC S9(7)V99 COMP-3
}
Constructors
FixedWidthBinaryFieldAttribute(int, int, BinaryFieldType)
Initializes a new FixedWidthBinaryFieldAttribute.
public FixedWidthBinaryFieldAttribute(int index, int byteLength, BinaryFieldType type)
Parameters
indexintThe zero-based column index; must be unique across the record.
byteLengthintThe field width in bytes (greater than zero).
typeBinaryFieldTypeHow the bytes are decoded.
Exceptions
- ArgumentOutOfRangeException
indexis negative orbyteLengthis not positive.
Properties
ByteLength
The field width in bytes.
public int ByteLength { get; }
Property Value
Index
The zero-based column index within the record.
public int Index { get; }
Property Value
Scale
The number of implied decimal places for a PackedDecimal field
(the V position in a COBOL picture). Ignored for other types. Default 0.
public int Scale { get; set; }
Property Value
Signed
public bool Signed { get; set; }
Property Value
Type
How the bytes are decoded.
public BinaryFieldType Type { get; }