开发者

AutoMapper IObjectMapper example

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜