Class CsvTypeMap<T, TValue>
Provides compile-time mapping to parse TValue
records from CSV.
public abstract class CsvTypeMap<T, TValue> : CsvTypeMap, IEquatable<CsvTypeMap<T, TValue>> where T : unmanaged, IBinaryInteger<T>
Type Parameters
T
Token type
TValue
Record type
- Inheritance
-
objectCsvTypeMap<T, TValue>
- Implements
-
IEquatable<CsvTypeMap<T, TValue>>
- Inherited Members
Remarks
Decorate a non-generic partial class with CsvTypeMapAttribute<T, TValue> to generate the implementation.
Properties
TargetType
Returns the mapped type.
protected override sealed Type TargetType { get; }
Property Value
Methods
BindForReading(CsvOptions<T>)
Returns a materializer for TValue
bound to field indexes.
protected virtual IMaterializer<T, TValue> BindForReading(CsvOptions<T> options)
Parameters
options
CsvOptions<T>
Returns
- IMaterializer<T, TValue>
Remarks
Caches the materializer based on the type and options. This can be overridden per type map.
BindForReading(ImmutableArray<string>, CsvOptions<T>)
Returns a materializer for TValue
bound to CSV header.
protected virtual IMaterializer<T, TValue> BindForReading(ImmutableArray<string> headers, CsvOptions<T> options)
Parameters
headers
ImmutableArray<string>options
CsvOptions<T>
Returns
- IMaterializer<T, TValue>
Remarks
Caches the materializer based on the type, headers, and options. This can be overridden per type map.
BindForWriting(CsvOptions<T>)
Returns a dematerializer for TValue
.
protected virtual IDematerializer<T, TValue> BindForWriting(CsvOptions<T> options)
Parameters
options
CsvOptions<T>
Returns
- IDematerializer<T, TValue>
Remarks
Caches the dematerializer based on the type and options. This can be overridden per type map.
Exceptions
- CsvBindingException
Options is configured not to write a header, but
TValue
has no index binding.
Equals(CsvTypeMap<T, TValue>?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CsvTypeMap<T, TValue>? other)
Parameters
other
CsvTypeMap<T, TValue>An object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GetDematerializer(CsvOptions<T>)
Returns a dematerializer for TValue
.
public IDematerializer<T, TValue> GetDematerializer(CsvOptions<T> options)
Parameters
options
CsvOptions<T>
Returns
- IDematerializer<T, TValue>
Remarks
Caches the dematerializer based on the type and options. This can be overridden per type map.
Exceptions
- CsvBindingException
Options is configured not to write a header, but
TValue
has no index binding.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetMaterializer(CsvOptions<T>)
Returns a materializer for TValue
bound to field indexes.
public IMaterializer<T, TValue> GetMaterializer(CsvOptions<T> options)
Parameters
options
CsvOptions<T>
Returns
- IMaterializer<T, TValue>
Remarks
Caches the materializer based on the type and options. This can be overridden per type map.
GetMaterializer(ImmutableArray<string>, CsvOptions<T>)
Returns a materializer for TValue
bound to CSV header.
public IMaterializer<T, TValue> GetMaterializer(ImmutableArray<string> headers, CsvOptions<T> options)
Parameters
headers
ImmutableArray<string>options
CsvOptions<T>
Returns
- IMaterializer<T, TValue>
Remarks
Caches the materializer based on the type, headers, and options. This can be overridden per type map.