Пример #1
0
 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);
         }
     }
 }
Пример #2
0
 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)));
 }
Пример #3
0
 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))));
 }
Пример #4
0
        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));
        }