Class CsvConfiguration
- Namespace
- CsvHelper.Configuration
- Assembly
- CsvHelper.dll
Configuration used for reading and writing CSV data.
public record CsvConfiguration : IReaderConfiguration, IParserConfiguration, IWriterConfiguration, IEquatable<CsvConfiguration>
- Inheritance
-
CsvConfiguration
- Implements
- Inherited Members
Constructors
CsvConfiguration(CsvConfiguration)
protected CsvConfiguration(CsvConfiguration original)
Parameters
original
CsvConfiguration
CsvConfiguration(CultureInfo)
Initializes a new instance of the CsvConfiguration class using the given CultureInfo. Since Delimiter uses CultureInfo for its default, the given CultureInfo will be used instead.
public CsvConfiguration(CultureInfo cultureInfo)
Parameters
cultureInfo
CultureInfoThe culture information.
CsvConfiguration(CultureInfo, Type)
Initializes a new instance of the CsvConfiguration class using the given CultureInfo. Since Delimiter uses CultureInfo for its default, the given CultureInfo will be used instead.
[Obsolete("This constructor is deprecated and will be removed in the next major release. Use CsvConfiguration(CultureInfo) instead.", false)]
public CsvConfiguration(CultureInfo cultureInfo, Type attributesType)
Parameters
cultureInfo
CultureInfoThe culture information.
attributesType
TypeThe type that contains the configuration attributes. This will call ApplyAttributes(Type) automatically.
Properties
AllowComments
public virtual bool AllowComments { get; set; }
Property Value
BadDataFound
public virtual BadDataFound? BadDataFound { get; set; }
Property Value
BufferSize
public virtual int BufferSize { get; set; }
Property Value
CacheFields
public virtual bool CacheFields { get; set; }
Property Value
Comment
public virtual char Comment { get; set; }
Property Value
CountBytes
public virtual bool CountBytes { get; set; }
Property Value
CultureInfo
public virtual CultureInfo CultureInfo { get; protected set; }
Property Value
Delimiter
public virtual string Delimiter { get; set; }
Property Value
DetectColumnCountChanges
public virtual bool DetectColumnCountChanges { get; set; }
Property Value
DetectDelimiter
public virtual bool DetectDelimiter { get; set; }
Property Value
DetectDelimiterValues
public virtual string[] DetectDelimiterValues { get; set; }
Property Value
- string[]
DynamicPropertySort
public virtual IComparer<string>? DynamicPropertySort { get; set; }
Property Value
Encoding
public virtual Encoding Encoding { get; set; }
Property Value
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Escape
public virtual char Escape { get; set; }
Property Value
ExceptionMessagesContainRawData
public virtual bool ExceptionMessagesContainRawData { get; set; }
Property Value
GetConstructor
public virtual GetConstructor GetConstructor { get; set; }
Property Value
GetDelimiter
public virtual GetDelimiter GetDelimiter { get; set; }
Property Value
GetDynamicPropertyName
public virtual GetDynamicPropertyName GetDynamicPropertyName { get; set; }
Property Value
HasHeaderRecord
public virtual bool HasHeaderRecord { get; set; }
Property Value
HeaderValidated
public virtual HeaderValidated? HeaderValidated { get; set; }
Property Value
IgnoreBlankLines
public virtual bool IgnoreBlankLines { get; set; }
Property Value
IgnoreReferences
public virtual bool IgnoreReferences { get; set; }
Property Value
IncludePrivateMembers
public virtual bool IncludePrivateMembers { get; set; }
Property Value
InjectionCharacters
public virtual char[] InjectionCharacters { get; set; }
Property Value
- char[]
InjectionEscapeCharacter
public virtual char InjectionEscapeCharacter { get; set; }
Property Value
InjectionOptions
public virtual InjectionOptions InjectionOptions { get; set; }
Property Value
IsNewLineSet
public bool IsNewLineSet { get; }
Property Value
LineBreakInQuotedFieldIsBadData
public virtual bool LineBreakInQuotedFieldIsBadData { get; set; }
Property Value
MaxFieldSize
public double MaxFieldSize { get; set; }
Property Value
MemberTypes
public virtual MemberTypes MemberTypes { get; set; }
Property Value
MissingFieldFound
public virtual MissingFieldFound? MissingFieldFound { get; set; }
Property Value
Mode
public virtual CsvMode Mode { get; set; }
Property Value
NewLine
public virtual string NewLine { get; set; }
Property Value
PrepareHeaderForMatch
public virtual PrepareHeaderForMatch PrepareHeaderForMatch { get; set; }
Property Value
ProcessFieldBufferSize
public virtual int ProcessFieldBufferSize { get; set; }
Property Value
Quote
public virtual char Quote { get; set; }
Property Value
ReadingExceptionOccurred
public virtual ReadingExceptionOccurred? ReadingExceptionOccurred { get; set; }
Property Value
ReferenceHeaderPrefix
public virtual ReferenceHeaderPrefix? ReferenceHeaderPrefix { get; set; }
Property Value
ShouldQuote
public ShouldQuote ShouldQuote { get; set; }
Property Value
ShouldSkipRecord
public virtual ShouldSkipRecord? ShouldSkipRecord { get; set; }
Property Value
ShouldUseConstructorParameters
public virtual ShouldUseConstructorParameters ShouldUseConstructorParameters { get; set; }
Property Value
TrimOptions
public virtual TrimOptions TrimOptions { get; set; }
Property Value
UseNewObjectForNullReferenceMembers
public virtual bool UseNewObjectForNullReferenceMembers { get; set; }
Property Value
WhiteSpaceChars
public virtual char[] WhiteSpaceChars { get; set; }
Property Value
- char[]
Methods
ApplyAttributes(Type)
Applies class level attribute to configuration.
public CsvConfiguration ApplyAttributes(Type type)
Parameters
type
TypeType with attributes.
Returns
ApplyAttributes<T>()
Applies class level attribute to configuration.
public CsvConfiguration ApplyAttributes<T>()
Returns
Type Parameters
T
Type with attributes.
Equals(CsvConfiguration?)
public virtual bool Equals(CsvConfiguration? other)
Parameters
other
CsvConfiguration
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
FromAttributes(Type)
Creates a CsvConfiguration instance configured using CsvHelper attributes applied
to type
at the type-level. This method requires type
to
be annotated with CultureInfoAttribute (or to sub-class a type which is).
public static CsvConfiguration FromAttributes(Type type)
Parameters
type
Type
Returns
- CsvConfiguration
A new CsvConfiguration instance configured with attributes applied to
type
.
Remarks
CsvHelper attributes applied to members and parameters do not influence the return value of this method. Such attributes do not define values which are used in CsvConfiguration and instead influence the maps which are built and used during reading and writing. See MemberMap and ParameterMap.
Exceptions
- ConfigurationException
If
type
is not annotated with CultureInfoAttribute.- ArgumentNullException
If the argument to the CultureInfoAttribute is null.
- CultureNotFoundException
If the argument to the CultureInfoAttribute does not specify a supported culture.
FromAttributes(Type, CultureInfo)
Creates a CsvConfiguration instance configured using cultureInfo
and CsvHelper attributes applied to type
at the type-level.
This method ignores any CultureInfoAttribute applied to type
.
public static CsvConfiguration FromAttributes(Type type, CultureInfo cultureInfo)
Parameters
type
TypecultureInfo
CultureInfo
Returns
- CsvConfiguration
A new CsvConfiguration instance configured with
cultureInfo
and attributes applied totype
Remarks
FromAttributes<T>()
Creates a CsvConfiguration instance configured using CsvHelper attributes applied
to T
at the type-level. This method requires T
to
be annotated with CultureInfoAttribute (or to sub-class a type which is).
public static CsvConfiguration FromAttributes<T>()
Returns
- CsvConfiguration
A new CsvConfiguration instance configured with attributes applied to
T
.
Type Parameters
T
The type whose attributes should be used to configure the CsvConfiguration instance. This is normally the type you are intending to map for reading and writing.
Remarks
CsvHelper attributes applied to members and parameters do not influence the return value of this method. Such attributes do not define values which are used in CsvConfiguration and instead influence the maps which are built and used during reading and writing. See MemberMap and ParameterMap.
Exceptions
- ConfigurationException
If
T
is not annotated with CultureInfoAttribute.- ArgumentNullException
If the argument to the CultureInfoAttribute is null.
- CultureNotFoundException
If the argument to the CultureInfoAttribute does not specify a supported culture.
FromAttributes<T>(CultureInfo)
Creates a CsvConfiguration instance configured using cultureInfo
and CsvHelper attributes applied to T
at the type-level.
This method ignores any CultureInfoAttribute applied to T
.
public static CsvConfiguration FromAttributes<T>(CultureInfo cultureInfo)
Parameters
cultureInfo
CultureInfoThe CultureInfo to configure the returned CsvConfiguration with.
Returns
- CsvConfiguration
A new CsvConfiguration instance configured with
cultureInfo
and attributes applied toT
.
Type Parameters
T
Remarks
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builder
StringBuilder
Returns
ToString()
public override string ToString()
Returns
Validate()
Validates the configuration.
public void Validate()
<Clone>$()
public virtual CsvConfiguration <Clone>$()
Returns
Operators
operator ==(CsvConfiguration?, CsvConfiguration?)
public static bool operator ==(CsvConfiguration? left, CsvConfiguration? right)
Parameters
left
CsvConfigurationright
CsvConfiguration
Returns
operator !=(CsvConfiguration?, CsvConfiguration?)
public static bool operator !=(CsvConfiguration? left, CsvConfiguration? right)
Parameters
left
CsvConfigurationright
CsvConfiguration