开发者

AutoMapper IObjectMapper example

开发者 https://www.devze.com 2023-03-17 11:19 出处:网络
In short, has anyone got one, including how to re开发者_运维知识库gister the custom mapper. I\'m trying to map a custom IList<T> implementation and am not getting very far.Just replace the Mapp

In short, has anyone got one, including how to re开发者_运维知识库gister the custom mapper.

I'm trying to map a custom IList<T> implementation and am not getting very far.


Just replace the MapperRegistry.AllMappers with a new list. Here's the default:

    public static Func<IEnumerable<IObjectMapper>> AllMappers = () => new IObjectMapper[]
    {
        new DataReaderMapper(),
        new TypeMapMapper(TypeMapObjectMapperRegistry.AllMappers()),
        new StringMapper(),
        new FlagsEnumMapper(),
        new EnumMapper(),
        new ArrayMapper(),
        new EnumerableToDictionaryMapper(),
        new DictionaryMapper(),
        new ListSourceMapper(),
        new ReadOnlyCollectionMapper(), 
        new CollectionMapper(),
        new EnumerableMapper(),
        new AssignableMapper(),
        new TypeConverterMapper(),
        new NullableMapper()
    };

You'd take this Func, and replace it with something else, with this set of code as a starting point.

Not the prettiest thing in the world, but at least it's possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消