CsvHelper icon indicating copy to clipboard operation
CsvHelper copied to clipboard

Centralize configuration for mapping

Open ayazaliuk101 opened this issue 9 years ago • 5 comments

Hi

I really like this tool however I was wondering if it was possible to centralize the mapping configuration in one location without the need to pass it around, as this can lead to polluting various projects. so every time I call the either it takes the default configuration set by me or allows me to override it.

Hope that make sense.

Regards

Ayaz

ayazaliuk101 avatar Jul 24 '17 19:07 ayazaliuk101

Does this scenario not work for you?

var csv = new CsvReader( someReader );
csv.Configuration.HasHeaderRecord = false;

JoshClose avatar Jul 24 '17 19:07 JoshClose

No, say for example I have mappers, and I want the csv reader to use those mapping classes every time I use the parser, I would have to pass the config around which makes it more difficult. Ideally you would call config once during start up or something, set up the configuration then every time CsvReader is instantiated that configuration would be injected into it or something like that.

On Mon, Jul 24, 2017 at 8:06 PM, Josh Close [email protected] wrote:

Does this scenario not work for you?

var csv = new CsvReader( someReader );csv.Configuration.HasHeaderRecord = false;

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoshClose/CsvHelper/issues/717#issuecomment-317523621, or mute the thread https://github.com/notifications/unsubscribe-auth/AdAkAxSHF6fJ8m28SsZFLuPKUJDIpQGfks5sROtHgaJpZM4Ohm1J .

ayazaliuk101 avatar Jul 24 '17 19:07 ayazaliuk101

That sounds like what an IoC container is used for.

JoshClose avatar Jul 24 '17 19:07 JoshClose

That's exactly what I do. IoC is the answer.

On Jul 24, 2017 3:41 PM, "Josh Close" [email protected] wrote:

That sounds like what an IoC container is used for.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JoshClose/CsvHelper/issues/717#issuecomment-317532443, or mute the thread https://github.com/notifications/unsubscribe-auth/AD_ohdQ6KXVChS7jRnK_y_nN5dGTdzXZks5sRPNtgaJpZM4Ohm1J .

jamesbascle avatar Jul 24 '17 20:07 jamesbascle

Closing this as I don't think it's the responsibility of this library.

JoshClose avatar Aug 21 '17 18:08 JoshClose