使用自定义转换器发射映射器奉承 [英] Emit Mapper Flattering with Custom Converters
问题描述
由于某种原因,使用此配置时,使用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屋!