public static IEnumerable <TTo> MapIfNotNull <TFrom, TTo>(IEnumerable <TFrom> from, Func <TFrom, TTo> doMapping) where TFrom : class where TTo : class { if (from != null) { foreach (TFrom tFrom in from) { TTo tTo = ClassMapper.MapIfNotNull <TFrom, TTo>(tFrom, doMapping); if (tTo == null) { continue; } yield return(tTo); } } }
public static TTo MapIfNotNull <TFrom, TTo>(TFrom from, Func <TFrom, TTo> doMapping) where TFrom : class where TTo : class { return(ClassMapper.MapIfNotNull <TFrom, TTo>(from, doMapping, default(TTo))); }
public IEnumerable <TTo> Map(IEnumerable <TFrom> from) { return(ClassMapper.MapIfNotNull <TFrom, TTo>(from, (TFrom partialFrom) => ClassMapper.MapIfNotNull <TFrom, TTo>(partialFrom, new Func <TFrom, TTo>(this.Map)))); }
public TTo Map(TFrom from, TTo defaultTo) { ClassMapper <TFrom, TTo> classMapper = this; return(ClassMapper.MapIfNotNull <TFrom, TTo>(from, new Func <TFrom, TTo>(classMapper.MapOne), defaultTo)); }