using System; using System.Collections.Generic; using System.Linq; namespace Mapster { public static class MapsterExtension { public static IEnumerable Adapt(this IEnumerable sourceList) { return sourceList.Select(item => item.Adapt()); } public static TDestination Adapt(this object source, Action afterMapAction = default) { var dest = source.Adapt(); afterMapAction?.Invoke(dest); return dest; } public static TDestination Adapt(this TSource source, Action afterMapAction = default) { var dest = source.Adapt(); afterMapAction?.Invoke(dest, source); return dest; } public static IEnumerable Adapt(this IEnumerable sourceList, Action eachAfterMapAction = default) { foreach (var item in sourceList) { var dest = item.Adapt(); eachAfterMapAction?.Invoke(dest, item); yield return dest; } } } }