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

index int

The zero-based column index; must be unique across the record.

byteLength int

The field width in bytes (greater than zero).

type BinaryFieldType

How the bytes are decoded.

Exceptions

ArgumentOutOfRangeException

index is negative or byteLength is not positive.

Properties

ByteLength

The field width in bytes.

public int ByteLength { get; }

Property Value

int

Index

The zero-based column index within the record.

public int Index { get; }

Property Value

int

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

int

Signed

Whether a Binary field is two's-complement signed. Ignored for other types. Default true.

public bool Signed { get; set; }

Property Value

bool

Type

How the bytes are decoded.

public BinaryFieldType Type { get; }

Property Value

BinaryFieldType