using AutoMapper; using AutoMapper.Configuration; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Yi.Framework.WebCore.Mapper { public class MapperHelper { public static IMapper Profile() { var cfg = new MapperConfigurationExpression(); cfg.AddProfile(); cfg.AddProfile(); var config = new MapperConfiguration(cfg); IMapper mapper = new AutoMapper.Mapper(config); return mapper; } public static Target Map(Source source) { var cfg = new MapperConfigurationExpression(); cfg.CreateMap(); var config = new MapperConfiguration(cfg); IMapper mapper = new AutoMapper.Mapper(config); return mapper.Map(source); } public static List MapList(List source) { var cfg = new MapperConfigurationExpression(); cfg.CreateMap(); var config = new MapperConfiguration(cfg); IMapper mapper = new AutoMapper.Mapper(config); return mapper.Map, List>(source); } } }