使用自定义转换器发射映射器奉承 [英] Emit Mapper Flattering with Custom Converters

查看:82
本文介绍了使用自定义转换器发射映射器奉承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,使用此配置时,使用EmitMapper Samples中的FlatteringConfig时不会调用Custom Converter的Conver函数.使用DefaultMapConfig时会调用它.

With this configuration for some reason Conver function of Custom Converter is not called when using FlatteringConfig from EmitMapper Samples. It is called, when DefaultMapConfig is used.

配置:

    var userMapper = ObjectMapperManager.DefaultInstance.GetMapper<User, UserModel>(
                   new FlatteringConfig().ConvertGeneric(typeof(IList<>), typeof(IList<>),
                new DefaultCustomConverterProvider(typeof(EntityListToModelListConverter<,>))));

关于潜在原因的任何想法吗?

Any ideas about the potential reason?

在下面查看我的答案

推荐答案

由于FlatteringConfig覆盖了GetMappingOperations函数,因此它没有调用FilterOpertations函数,后者分配了自定义转换器.因此,将FilterOperations函数调用添加到GetMappingOperations可以解决此问题.

Because FlatteringConfig overrides GetMappingOperations function it is not calling FilterOpertations functions, which assigns custom converters. So adding FilterOperations function call to the GetMappingOperations solved the problem.

这篇关于使用自定义转换器发射映射器奉承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆