With CsvHelper, when I want a custom parser (for example, I want a MyBooleanConverter
with the input string is "f" will be false, "t" will be "true"). But with every class I have to write mapper:
public sealed class MyClassMap : CsvClassMap<MyClass>
{
public MyClassMap()
{
Map( m => m.Id ).Index( 0 ).TypeConverter<MyBooleanConverter>();
}
}
Or
[CsvHelper.TypeConversion.TypeConverter( typeof( MyBooleanConverter) )]
public Boolean MyObjectProperty { get; set; }
How can I set MyBooleanConverter
as default for every boolean field and every Class?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…