forked from ddrilling/AsbCloudServer
30 lines
986 B
C#
30 lines
986 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Mapster
|
|||
|
{
|
|||
|
public static class MapsterExtension
|
|||
|
{
|
|||
|
public static IEnumerable<TDestination> Adapt<TDestination>(this IEnumerable<object> sourceList)
|
|||
|
{
|
|||
|
foreach (var item in sourceList)
|
|||
|
yield return item.Adapt<TDestination>();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static TDestination Adapt<TSource, TDestination>(this TSource source, Action<TSource, TDestination> afterMapAction = default)
|
|||
|
{
|
|||
|
var dest = source.Adapt<TDestination>();
|
|||
|
if (afterMapAction != default)
|
|||
|
afterMapAction(source, dest);
|
|||
|
return dest;
|
|||
|
}
|
|||
|
|
|||
|
public static IEnumerable<TDestination> Adapt<TSource, TDestination>(this IEnumerable<TSource> sourceList, Action<TSource, TDestination> eachAfterMapAction = default)
|
|||
|
{
|
|||
|
foreach (var item in sourceList)
|
|||
|
yield return item.Adapt(eachAfterMapAction);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|