【发布时间】:2011-12-31 09:59:33
【问题描述】:
ITypeConverter 接口已更改为具有用于 Convert 方法的“Tdestination Convert(ResolutionContext context)”而不是“Tdestination Convert(TSource source)”。
http://automapper.codeplex.com/wikipage?title=Custom%20Type%20Converters
在我的代码中,现在我得到了这个错误:
'BusinessFacade.Mappers.DecimalToNullableInt' 没有实现 接口成员 'AutoMapper.ITypeConverter.Convert(AutoMapper.ResolutionContext)'
像我的映射器这样的新映射器有什么好的完整示例吗?我不想在我的项目中更改任何代码(或最小代码)...
我的映射器
public class DecimalToNullableInt : ITypeConverter<decimal, int?>
{
public int? Convert(decimal source)
{
if (source == 0)
return null;
return (int)source;
}
}
更新
ITypeConverter 接口已更改为具有用于 Convert 方法的“Tdestination Convert(ResolutionContext context)”而不是“Tdestination Convert(TSource source)”。
文档刚刚过时。有一个 ITypeConverter,如 以及一个基本的 TypeConverter 便利类。 TypeConverter 隐藏了 ResolutionContext,而 ITypeConverter 公开它。
http://automapper.codeplex.com/wikipage?title=Custom%20Type%20Converters
https://github.com/AutoMapper/AutoMapper/wiki/Custom-type-converters
http://groups.google.com/group/automapper-users/browse_thread/thread/6c523b95932f4747
【问题讨论】:
标签: versioning automapper