views:

155

answers:

1

I am using AutoMapper 1.0 RTW and adding a couple of custom formatters:

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

The destination types are both string and the formatters work individually. But put them together and only the first formatter gets called. In this case the "AlertTypeFormatter".

Any ideas?

A: 

Fixed. For future reference, Mapper.AddFormatter actually sets up the default formatter that Automap will use. To setup type specific formatters you need to use:

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

Doh...

ozczecho
Any idea where I am going wrong with setting up the general formatters? http://stackoverflow.com/questions/2779068/automapper-site-wide-usage-of-ivalueformatter-for-given-types
CRice