CsvFieldMapping Class
Definition
Namespace: DataStandardizer.File.CSV
The details of a single mapping between a CSV field and a model property: the field identity, optionality, constant or generated value, converters, and the property type.
Syntax
public sealed class CsvFieldMapping
Remarks
You do not construct or set this type directly — its constructor and property setters are internal. Mappings are built from CsvFieldMappingAttribute declarations or through the fluent CsvFileMappingBuilder, and surfaced (read-only) through a CsvFileMapper / ICsvFileMapper. The properties below are all publicly readable.
When FromStringConverter isn’t set, and TypeConverterType isn’t set or names a TypeConverter that doesn’t convert from a string, a reader parses the field with its built-in parse for PropertyType. See converting field values.
Properties
| Property | Signature | Notes |
|---|---|---|
ConstantValue | object? ConstantValue { get; } | A constant value for the field. |
FieldIndex | int? FieldIndex { get; } | The mapped field index. Setting a negative value throws ArgumentOutOfRangeException. |
FieldName | string? FieldName { get; } | The mapped field name. |
FromStringConverter | Delegate? FromStringConverter { get; } | A CsvFieldConvertFromString delegate (reading only). Takes precedence over TypeConverterType and the reader’s built-in parse. |
IsOptional | bool IsOptional { get; } | true if the field is optional. |
PropertyType | Type PropertyType { get; } | The type of the mapped property. |
ToStringConverter | Delegate? ToStringConverter { get; } | A CsvFieldConvertToString delegate (writing only). |
UseFieldName | string? UseFieldName { get; } | The name the field is known by once read, in place of its name in the file, or null if it keeps that name. See header lines that repeat a name. |
TypeConverterType | Type? TypeConverterType { get; } | The TypeConverter type used for (de)serialization. When reading, a converter that converts from a string takes precedence over the reader’s built-in parse, and a value the converter throws for is a bad value. One that doesn’t convert from a string isn’t used when reading. |
Validator | Delegate? Validator { get; } | A CsvFieldValidate delegate. |
VariableValueGenerator | Delegate? VariableValueGenerator { get; } | A CsvFieldGenerate delegate. |
Applies to
Targets netstandard1.1, netstandard2.0, netstandard2.1, and net10.0. The nullable reference annotations apply to the netstandard2.1 and net10.0 builds.