Table of Contents

Class CsvBinding

Namespace
FlameCsv.Binding
Assembly
FlameCsv.Core.dll

Base class representing a binding of a member or parameter to a CSV field.

[EditorBrowsable(EditorBrowsableState.Advanced)]
public abstract class CsvBinding : IComparable<CsvBinding>
Inheritance
CsvBinding
Implements
Derived

Properties

DeclaringType

Returns the declaring type of the target.

public abstract Type? DeclaringType { get; }

Property Value

Type

Header

The CSV field header of this binding (optional).

public string? Header { get; }

Property Value

string

Index

The CSV field index of this binding.

public int Index { get; }

Property Value

int

IsIgnored

Returns whether the binding is on an ignored field.

public bool IsIgnored { get; }

Property Value

bool

Sentinel

Equality contract of the binding. The target of the binding (member or parameter), or typeof CsvIgnored if ignored field.

protected abstract object Sentinel { get; }

Property Value

object

Type

Returns the type of the binding's target (property/field/parameter type). For ignored fields, returns typeof(object).

public abstract Type Type { get; }

Property Value

Type

Exceptions

InvalidOperationException

Methods

AreSame(object?, object?)

Returns true if the objects are the same instance, or both are the same member.

protected static bool AreSame(object? a, object? b)

Parameters

a object
b object

Returns

bool

CompareTo(CsvBinding?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(CsvBinding? other)

Parameters

other CsvBinding

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

ForMember<T>(int, MemberInfo, string?)

Returns a binding for the specified member.

[RequiresDynamicCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvBinding<T> ForMember<T>(int index, MemberInfo member, string? header = null)

Parameters

index int
member MemberInfo
header string

Returns

CsvBinding<T>

Type Parameters

T

Exceptions

CsvBindingException<T>

ForParameter<T>(int, ParameterInfo)

Returns a binding for the specified parameter.

public static CsvBinding<T> ForParameter<T>(int index, ParameterInfo parameter)

Parameters

index int
parameter ParameterInfo

Returns

CsvBinding<T>

Type Parameters

T

Exceptions

CsvBindingException<T>

For<T>(int, Expression<Func<T, object?>>)

Returns a binding for the specified member.

[RequiresDynamicCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvBinding<T> For<T>(int index, Expression<Func<T, object?>> memberExpression)

Parameters

index int
memberExpression Expression<Func<T, object>>

Returns

CsvBinding<T>

Type Parameters

T

Ignore<T>(int)

Returns a binding that ignores the field at index.

public static CsvBinding<T> Ignore<T>(int index)

Parameters

index int

Returns

CsvBinding<T>

Type Parameters

T

TargetEquals(CsvBinding?)

Returns whether the binding targets the same property/field/parameter, or both bindings are ignored fields.

public bool TargetEquals(CsvBinding? other)

Parameters

other CsvBinding

Returns

bool