CsvMapping Class

Mapping for CsvRecord instances.

Definition

Namespace: FolkerKinzel.CsvTools.Mappings
Assembly: FolkerKinzel.CsvTools.Mappings (in FolkerKinzel.CsvTools.Mappings.dll) Version: 1.1.0+1263e8243dc2cd78095f678f813d7d9c52ea4315
C#
public sealed class CsvMapping : DynamicObject, 
	IEnumerable<DynamicProperty>, IEnumerable, ICloneable
Inheritance
Object    DynamicObject    CsvMapping
Implements
IEnumerableDynamicProperty, IEnumerable, ICloneable

Remarks

Use CsvMappingBuilder to create an instance.

The class allows you to index the data of the CsvRecord object in a sequence of your choice, to access the data with .NET properties dynamically implemented at runtime ("late binding"), and to perform type conversions automatically. In order to be able to use the dynamic properties of the CsvMapping class like regular .NET properties, the CsvMapping instance has to be assigned to a variable that is declared with the keyword dynamic.

Use the methods of the CsvConverter class or the corresponding extension methods to perform read and write operations with the CsvMapping.

In order to support high-performance scenarios, the DynamicProperty instances of the CsvMapping alternatively can be accessed directly without having to use dynamic .NET properties:

With this approach boxing and unboxing of value types can be avoided.

Unfortunately, for dynamic properties, the compiler does not monitor the nullability of reference types. With the high-performance approach just presented this can be avoided, but a critical point here is the correct type cast with the AsITypedPropertyT(DynamicProperty) method: Make sure that you choose the correct nullability of the reference types here. The compiler can't check this.

Properties

Count Gets the number of DynamicProperty instances in the CsvMapping.
ItemInt32 Gets the DynamicProperty with the specified index.
ItemString Gets the DynamicProperty with the specified PropertyName.
PropertyNames Returns the property names, which are currently registered in the CsvMapping.
Record Gets or sets the CsvRecord instance whose data is accessed with dynamic properties.
RegexTimeout Maximum time (in milliseconds) that can be used to resolve a CSV column name alias.

Methods

CloneCreates a new object that is a copy of the current instance.
Contains Examines whether a DynamicProperty instance is registered in the CsvMapping under the name that is specified with propertyName.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
GetEnumeratorReturns an enumerator that iterates through the collection.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Overrides ObjectToString)

Extension Methods

SaveCsvDynamicProperty Saves a collection of TSource instances as a CSV file with header row.
(Defined by CsvConverterExtension)
SaveCsvDynamicProperty Saves a collection of TSource instances as a CSV file without header row.
(Defined by CsvConverterExtension)
SaveCsvDynamicProperty Saves a collection of TSource instances as a CSV file with header row.
(Defined by CsvConverterExtension)
SaveCsvDynamicProperty Saves a collection of TSource instances as a CSV file without header row.
(Defined by CsvConverterExtension)
ToCsvDynamicProperty Converts a collection of TSource instances to a CSV String with header row.
(Defined by CsvConverterExtension)
ToCsvDynamicProperty Converts a collection of TSource instances to a CSV String without a header row.
(Defined by CsvConverterExtension)
ToCsvDynamicProperty Converts a collection of TSource instances to a CSV String with header row.
(Defined by CsvConverterExtension)
ToCsvDynamicProperty Converts a collection of TSource instances to a CSV String without a header row.
(Defined by CsvConverterExtension)

Explicit Interface Implementations

IEnumerableGetEnumeratorReturns an enumerator that iterates through a collection.

Thread Safety

Static members of this type are not safe for multi-threaded operations. Instance members of this type are not safe for multi-threaded operations.

See Also