Class ClassMap
- Namespace
- CsvHelper.Configuration
- Assembly
- CsvHelper.dll
Maps class members to CSV fields.
public abstract class ClassMap
- Inheritance
-
ClassMap
- Derived
- Inherited Members
Properties
ClassType
The type of the class this map is for.
public virtual Type ClassType { get; }
Property Value
MemberMaps
The class member mappings.
public virtual MemberMapCollection MemberMaps { get; }
Property Value
ParameterMaps
The class constructor parameter mappings.
public virtual List<ParameterMap> ParameterMaps { get; }
Property Value
ReferenceMaps
The class member reference mappings.
public virtual MemberReferenceMapCollection ReferenceMaps { get; }
Property Value
Methods
ApplyAttributes(MemberMap)
Applies attribute configurations to the map.
protected virtual void ApplyAttributes(MemberMap memberMap)
Parameters
memberMapMemberMapThe member map.
ApplyAttributes(MemberReferenceMap)
Applies attribute configurations to the map.
protected virtual void ApplyAttributes(MemberReferenceMap referenceMap)
Parameters
referenceMapMemberReferenceMapThe member reference map.
ApplyAttributes(ParameterMap)
Applies attribute configurations to the map.
protected virtual void ApplyAttributes(ParameterMap parameterMap)
Parameters
parameterMapParameterMapThe parameter map.
ApplyAttributes(ParameterReferenceMap)
Applies attribute configurations to the map.
protected virtual void ApplyAttributes(ParameterReferenceMap referenceMap)
Parameters
referenceMapParameterReferenceMapThe parameter reference map.
AutoMap(CsvConfiguration)
Auto maps all members for the given type. If a member is mapped again it will override the existing map.
public virtual void AutoMap(CsvConfiguration configuration)
Parameters
configurationCsvConfigurationThe configuration.
AutoMap(CsvContext)
Auto maps all members for the given type. If a member is mapped again it will override the existing map.
public virtual void AutoMap(CsvContext context)
Parameters
contextCsvContextThe context.
AutoMap(CultureInfo)
Auto maps all members for the given type. If a member is mapped again it will override the existing map.
public virtual void AutoMap(CultureInfo culture)
Parameters
cultureCultureInfoThe culture.
AutoMapConstructorParameters(ClassMap, CsvContext, LinkedList<Type>, int)
Auto maps the given map using constructor parameters.
protected virtual void AutoMapConstructorParameters(ClassMap map, CsvContext context, LinkedList<Type> mapParents, int indexStart = 0)
Parameters
mapClassMapThe map.
contextCsvContextThe context.
mapParentsLinkedList<Type>The list of parents for the map.
indexStartintThe index starting point.
AutoMapMembers(ClassMap, CsvContext, LinkedList<Type>, int)
Auto maps the given map and checks for circular references as it goes.
protected virtual void AutoMapMembers(ClassMap map, CsvContext context, LinkedList<Type> mapParents, int indexStart = 0)
Parameters
mapClassMapThe map to auto map.
contextCsvContextThe context.
mapParentsLinkedList<Type>The list of parents for the map.
indexStartintThe index starting point.
CheckForCircularReference(Type, LinkedList<Type>)
Checks for circular references.
protected virtual bool CheckForCircularReference(Type type, LinkedList<Type> mapParents)
Parameters
typeTypeThe type to check for.
mapParentsLinkedList<Type>The list of parents to check against.
Returns
- bool
A value indicating if a circular reference was found. True if a circular reference was found, otherwise false.
GetGenericType()
Gets the generic type for this class map.
protected virtual Type GetGenericType()
Returns
GetMaxIndex(bool)
Get the largest index for the members and references.
public virtual int GetMaxIndex(bool isParameter = false)
Parameters
isParameterbool
Returns
- int
The max index.
Map()
Maps a non-member to a CSV field. This allows for writing data that isn't mapped to a class member.
public virtual MemberMap<object, object> Map()
Returns
Map(Type, MemberInfo, bool)
Maps a member to a CSV field.
public MemberMap Map(Type classType, MemberInfo member, bool useExistingMap = true)
Parameters
classTypeTypeThe type of the class this map is for. This may not be the same type as the member.DeclaringType or the current ClassType due to nested member mappings.
memberMemberInfoThe member to map.
useExistingMapboolIf true, an existing map will be used if available. If false, a new map is created for the same member.
Returns
- MemberMap
The member mapping.
Parameter(Func<ConstructorInfo>, string)
Maps a constructor parameter to a CSV field.
public virtual ParameterMap Parameter(Func<ConstructorInfo> getConstructor, string name)
Parameters
getConstructorFunc<ConstructorInfo>A function that returns the ConstructorInfo for the constructor.
namestringThe name of the constructor parameter.
Returns
Parameter(ConstructorInfo, ParameterInfo)
Maps a constructor parameter to a CSV field.
public virtual ParameterMap Parameter(ConstructorInfo constructor, ParameterInfo parameter)
Parameters
constructorConstructorInfoThe ConstructorInfo for the constructor.
parameterParameterInfoThe ParameterInfo for the constructor parameter.
Returns
Parameter(string)
Maps a constructor parameter to a CSV field.
public virtual ParameterMap Parameter(string name)
Parameters
namestringThe name of the constructor parameter.
Returns
ReIndex(int)
Resets the indexes based on the given start index.
public virtual int ReIndex(int indexStart = 0)
Parameters
indexStartintThe index start.
Returns
- int
The last index + 1.
References(Type, MemberInfo, params object[])
Maps a member to another class map.
public virtual MemberReferenceMap References(Type classMapType, MemberInfo member, params object[] constructorArgs)
Parameters
classMapTypeTypeThe type of the class map.
memberMemberInfoThe member.
constructorArgsobject[]Constructor arguments used to create the reference map.
Returns
- MemberReferenceMap
The reference mapping for the member.