Beispiel #1
0
        private static Action <object, IEnumerable <DataEntity> > MakeSetter(Action <object, object> setValue, ObjDefs objDefHeader, ISettablePropertyDef context, Type targetType, string deType)
        {
            return((target, val) =>
            {
                if (target == null)
                {
                    ThrowHelper.ThrowSetterTargetNull(context);
                }
                if (val == null)
                {
                    setValue(target, null);
                    return;
                }
                var tVal = val.Select(x => ObjDefConverter.From <T>(x, objDefHeader, deType));

                if (targetType.IsArray)
                {
                    setValue(target, tVal.ToArray());
                    return;
                }

                if (targetType.GetGenericTypeDefinition() == typeof(List <>))
                {
                    setValue(target, tVal.ToList());
                    return;
                }

                setValue(target, tVal);
                return;
            });
        }
Beispiel #2
0
 private static Action <object, DataEntity> MakeSetter(Action <object, object> setValue, ObjDefs objDefHeaders, ISettablePropertyDef context, string objDefName)
 {
     return((target, val) =>
     {
         if (target == null)
         {
             ThrowHelper.ThrowSetterTargetNull(context);
         }
         var tVal = ObjDefConverter.From <T>(val, objDefHeaders, objDefName);
         setValue(target, tVal);
     });
 }
Beispiel #3
0
 private static Func <object, QueryEntity, DataEntity> MakeQGetter(Func <object, object> getValue, ObjDefs objDefHeader, ISettablePropertyDef context)
 {
     return((target, qe) =>
     {
         if (target == null)
         {
             ThrowHelper.ThrowGetterTargetNull(context);
         }
         var val = getValue(target);
         if (val == null)
         {
             return null;
         }
         var de = ObjDefConverter.To((T)val, objDefHeader, qe);
         return de;
     });
 }
Beispiel #4
0
 private static Func <object, QueryEntity, List <DataEntity> > MakeQGetter(Func <object, object> getValue, ObjDefs objDefHeader, ISettablePropertyDef context)
 {
     return((target, qe) =>
     {
         if (target == null)
         {
             ThrowHelper.ThrowGetterTargetNull(context);
         }
         var val = getValue(target);
         if (val == null)
         {
             return null;
         }
         var ie = val as IEnumerable <T>;
         var des = ie.Select(x => ObjDefConverter.To(x, objDefHeader, qe));
         return des.ToList();
     });
 }