AutoMapper - adding custom formats

I use AutoMapper 1.0 RTW and add a couple of custom formatters:

    Mapper.AddFormatter<AlertTypeFormatter>(); 
    Mapper.AddFormatter<DateStringFormatter>();

Destination types are both string and formatters work individually. But group them, and only the first formatter is called. In this case, "AlertTypeFormatter".

Any ideas?

+3
source share
1 answer

Fixed. For future reference, Mapper.AddFormatter actually sets the default format formats that Automap will use. To configure the formatter type, you need to use:

Mapper.ForSourceType<DateTime>().AddFormatter<DateStringFormatter>();

Doh ...

+4
source

Source: https://habr.com/ru/post/1731823/


All Articles