Class FixedWidthSchema
- Namespace
- Wolfgang.Etl.FixedWidth
- Assembly
- Wolfgang.Etl.FixedWidth.dll
A read-only view over the resolved fixed-width field layout for a record type
(#22). Exposes the field/skip columns, positions, widths, types, and formatting
that FixedWidthExtractor<TRecord> / FixedWidthLoader<TRecord>
derive from [FixedWidthField] / [FixedWidthSkip] attributes — useful
for generating documentation, building validation tooling, or debugging a layout.
public sealed class FixedWidthSchema
- Inheritance
-
FixedWidthSchema
- Inherited Members
Examples
var schema = FixedWidthSchema.For<CustomerRecord>();
foreach (var field in schema.Fields)
{
Console.WriteLine($"{field.StartPosition}-{field.EndPosition} {field.Name} ({field.Length})");
}
Console.WriteLine($"Line width: {schema.ExpectedLineWidth}");
Properties
ExpectedLineWidth
The total line width in characters, including skipped columns.
public int ExpectedLineWidth { get; }
Property Value
FieldCount
The number of mapped fields, excluding skipped columns.
public int FieldCount { get; }
Property Value
Fields
All resolved columns in position order, including skipped columns
(IsSkip). Filter on !IsSkip for the
mapped fields only.
public IReadOnlyList<FixedWidthFieldInfo> Fields { get; }
Property Value
RecordType
The record type this schema describes.
public Type RecordType { get; }
Property Value
SkipCount
The number of skipped columns.
public int SkipCount { get; }
Property Value
TotalColumnCount
The total number of columns, including skipped columns.
public int TotalColumnCount { get; }
Property Value
Methods
For(Type)
Resolves the schema for recordType.
public static FixedWidthSchema For(Type recordType)
Parameters
recordTypeType
Returns
Exceptions
- ArgumentNullException
recordTypeis null.
For<T>()
Resolves the schema for record type T. Applies the same
validation as extraction/loading, so an invalid layout (duplicate column
indexes, a mapped field with no public setter) throws here too.
public static FixedWidthSchema For<T>() where T : notnull
Returns
Type Parameters
T
ToDiagram()
Renders the resolved layout as a human-readable text table for debugging,
logging, and documentation (#24). Columns line up on their widest cell; lines
are separated by \n and carry no trailing whitespace.
public string ToDiagram()
Returns
Examples
Console.WriteLine(FixedWidthSchema.For<CustomerRecord>().ToDiagram());