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