I\'m trying to have AutoMapper take care of localizing all DateTime properties on our view models for us. We use UTC everywhere in our system and store everything in UTC in the
Yes - but with a slight change in ordering of the MapperRegistry. First, create a type converter from DateTime to DateTime:
Mapper.CreateMap().ConvertUsing();
Your CompanyTimeConverter code looks pretty much like the value resolver you had, except it inherits from TypeConverter.
Next, you have to change the order of the MapperRegistry (I'm going to change this going forward, it makes more sense):
MapperRegistry.AllMappers = () => new IObjectMapper[] {
new DataReaderMapper(),
new TypeMapMapper(TypeMapObjectMapperRegistry.AllMappers()),
new StringMapper(),
new FlagsEnumMapper(),
new EnumMapper(),
new ArrayMapper(),
new EnumerableToDictionaryMapper(),
new DictionaryMapper(),
new ListSourceMapper(),
new CollectionMapper(),
new EnumerableMapper(),
new TypeConverterMapper(),
new AssignableMapper(),
new NullableMapper()
};
Originally, the "Assignable" mapper came before the "TypeConverter" mapper, so that if two types were assignable to each other, it would just do that.