public void CustomTypeDemo() { Source2 source = new Source2 { FltConstructFee = 100.1m, FuelCostFee = 100.2m, TaxFee = 100.3m, DateString = "08/22/2016", Name = "朱自清" }; Mapper.Initialize(cfg => { cfg.CreateMap <Source2, Destination2>().ConvertUsing(new DateTimeTypeConverter()); }); Destination2 destination = Mapper.Map <Source2, Destination2>(source); }
public void CustomValueDemo() { Source2 source = new Source2 { FltConstructFee = 100.1m, FuelCostFee = 100.2m, TaxFee = 100.3m, DateString = "08/22/2016", Name = "朱自清" }; Mapper.Initialize(cfg => { cfg.CreateMap <Source2, Destination2>() //自定义解析器 .ForMember(dest => dest.TotalWithTax, opt => opt.ResolveUsing <CustomResolver>());; }); Destination2 destination = Mapper.Map <Source2, Destination2>(source); }