Ejemplo n.º 1
0
        public void DoConvert(ParamConvertConfig c, IContext context)
        {
            var arg      = c.Args.First();
            var delegte1 = EvalHelper.GetDelegate(context, arg);

            ParamConvertUtil.StoreToParams(context, c, delegte1.DynamicInvoke());
        }
Ejemplo n.º 2
0
        public bool Continue(Context context)
        {
            var conditionSetting = GetConditionModel(context);
            var @delegate        = EvalHelper.GetDelegate(context, conditionSetting.Eval);

            return((bool)@delegate.DynamicInvoke());
        }
Ejemplo n.º 3
0
        public bool Checked(UpdateContext context, ColumnRule mc, object data, string key, string realKey)
        {
            var eval   = mc.Value.ToString();
            var action = context.ContentParams.CreateOrGet <string, object, Delegate>(eval, expression =>
            {
                return(EvalHelper.GetDelegate(context, expression, data));
            });

            return((bool)action.DynamicInvoke(data));
        }
Ejemplo n.º 4
0
        public bool WhetheResultStop(Context context, object result)
        {
            var conditionSetting = GetConditionModel(context);

            if (string.IsNullOrEmpty(conditionSetting.ResultEval))
            {
                return(false);
            }

            var @delegate = EvalHelper.GetDelegate(context, conditionSetting.ResultEval, result);

            return((bool)@delegate.DynamicInvoke(result));
        }
Ejemplo n.º 5
0
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var eval   = EvalHelper.GetDelegate(context, segment.ArgContext);
            var result = (bool)eval.DynamicInvoke();

            if (!result)
            {
                return(string.Empty);
            }

            var content = SegmentUtil.GetContent(oldSql, segment);

            return(SegmentUtil.BuildContent(context, oldSql, content, segment));
        }
        protected static IEnumerable<object> GetDatas(UpdateContext context, UpdateConfig config, object complexData)
        {
            string field = string.Empty;
            if (config.Config != null && config.Config[BatchFieldPath] != null)
            {
               field = config.Config[BatchFieldPath].ToSingleData<string>(string.Empty);
            }

            bool isArray;
            object inputData;
            if (string.IsNullOrEmpty(field))
            {
                isArray = ReflectUtil.ReflectUtil.IsArray(complexData);
                inputData = complexData;
            }
            else
            {
                var array = field.Split('.');
                var valueInfo = ValueGetter.GetValue(array, complexData);
                isArray = valueInfo.IsArray;
                inputData = valueInfo.Data;
            }

            IEnumerable<object> results;
            if (!isArray)
            {
                results = new object[] { inputData };
            }
            else {
                results = (IEnumerable<object>)inputData;
            }

            var filterEval = config.Config[FilterEval].ToSingleData<string>(string.Empty);
            if (string.IsNullOrEmpty(filterEval) || results.Any() == false)
            {
                return results;
            }

            var action = context.ContentParams.CreateOrGet<string, object, Delegate>(filterEval, eval =>
            {
                return EvalHelper.GetDelegate(context, filterEval, results.First());
            });
            
            results = results.Where(r => (bool)action.DynamicInvoke(r)).ToArray();
            return results;
        }