namespace zero.Mapper; public static class MapperExtensions { //public static TDestination Register(this IZeroMapper mapper, Action map) where TDestination : class, new() //{ //} //public static TDestination Register(this IZeroMapper mapper, Action map, TDestination destination) //{ //} public static TDestination Map(this IZeroMapper mapper, TSource source, TDestination destination) { return mapper.Map(source, typeof(TSource), destination); } public static TDestination Map(this IZeroMapper mapper, TSource source) { return mapper.Map(source, typeof(TSource), default); } public static Paged Map(this IZeroMapper mapper, Paged source, Action modify = null) { return source.MapTo(srcItem => { TDestination destination = mapper.Map(srcItem); modify?.Invoke(srcItem, destination); return destination; }); } public static Result Map(this IZeroMapper mapper, Result source) { TDestination model = mapper.Map(source.Model); return source.ConvertTo(model); } public static Dictionary Map(this IZeroMapper mapper, Dictionary source) { Dictionary model = new(); foreach ((string key, TSource sourceItem) in source) { model.Add(key, sourceItem == null ? default : mapper.Map(sourceItem)); } return model; } public static IEnumerable Map(this IZeroMapper mapper, IEnumerable source) { return source.Select(x => mapper.Map(x)); } }