我在stackoverflow上找到了这个代码,但我注意到它无法处理FlatLoopValueInjection,我想让它处理这个但我无法弄清楚如何。
public static ICollection<TTo> InjectFrom<TFrom, TTo>(this ICollection<TTo> to, IEnumerable<TFrom> from) where TTo : new()
{
foreach (var source in from)
{
var target = new TTo();
target.InjectFrom(source);
to.Add(target);
}
return to;
}
我知道这需要更新target.InjectFrom(source);
但是我不确定它是什么,如果它可以采取任何(FlatLoopValueInjection,UnflatLoopValueInjection等)并使用它