Table of Contents

Class CsvContext

Namespace
CsvHelper
Assembly
CsvHelper.dll

Share state for CsvHelper.

public class CsvContext
Inheritance
CsvContext
Inherited Members

Constructors

CsvContext(CsvConfiguration)

Initializes a new instance of the CsvContext class.

public CsvContext(CsvConfiguration configuration)

Parameters

configuration CsvConfiguration

The configuration.

CsvContext(IParser)

Initializes a new instance of the CsvContext class.

public CsvContext(IParser parser)

Parameters

parser IParser

The parser.

CsvContext(IReader)

Initializes a new instance of the CsvContext class.

public CsvContext(IReader reader)

Parameters

reader IReader

The reader.

CsvContext(IWriter)

Initializes a new instance of the CsvContext class.

public CsvContext(IWriter writer)

Parameters

writer IWriter

The writer.

Properties

Configuration

Gets the configuration.

public CsvConfiguration Configuration { get; }

Property Value

CsvConfiguration

Maps

The configured ClassMaps.

public virtual ClassMapCollection Maps { get; }

Property Value

ClassMapCollection

Parser

Gets the parser.

public IParser? Parser { get; }

Property Value

IParser

Reader

Gets the reader.

public IReader? Reader { get; }

Property Value

IReader

TypeConverterCache

Gets or sets the TypeConverterOptionsCache.

public virtual TypeConverterCache TypeConverterCache { get; set; }

Property Value

TypeConverterCache

TypeConverterOptionsCache

Gets or sets the TypeConverterOptionsCache.

public virtual TypeConverterOptionsCache TypeConverterOptionsCache { get; set; }

Property Value

TypeConverterOptionsCache

Writer

Gets the writer.

public IWriter? Writer { get; }

Property Value

IWriter

Methods

AutoMap(Type)

Generates a ClassMap for the type.

public virtual ClassMap AutoMap(Type type)

Parameters

type Type

The type to generate for the map.

Returns

ClassMap

The generate map.

AutoMap<T>()

Generates a ClassMap for the type.

public virtual ClassMap<T> AutoMap<T>()

Returns

ClassMap<T>

The generate map.

Type Parameters

T

The type to generate the map for.

RegisterClassMap(ClassMap)

Registers the class map.

public virtual void RegisterClassMap(ClassMap map)

Parameters

map ClassMap

The class map to register.

RegisterClassMap(Type)

Use a ClassMap<TClass> to configure mappings. When using a class map, no members are mapped by default. Only members specified in the mapping are used.

public virtual ClassMap RegisterClassMap(Type classMapType)

Parameters

classMapType Type

The type of mapping class to use.

Returns

ClassMap

RegisterClassMap<TMap>()

Use a ClassMap<TClass> to configure mappings. When using a class map, no members are mapped by default. Only member specified in the mapping are used.

public virtual TMap RegisterClassMap<TMap>() where TMap : ClassMap

Returns

TMap

Type Parameters

TMap

The type of mapping class to use.

UnregisterClassMap()

Unregisters all class maps.

public virtual void UnregisterClassMap()

UnregisterClassMap(Type)

Unregisters the class map.

public virtual void UnregisterClassMap(Type classMapType)

Parameters

classMapType Type

The map type to unregister.

UnregisterClassMap<TMap>()

Unregisters the class map.

public virtual void UnregisterClassMap<TMap>() where TMap : ClassMap

Type Parameters

TMap

The map type to unregister.