Beispiel #1
0
        public RuleResult Execute(Rule rule, IDictionary <string, object> input)
        {
            var compileExpr = expressionCompiler.Compile(rule.RuleExpression, input);
            var obj         = ExpressionEvaluator.Eval(compileExpr);

            rule.Success = Convert.ToBoolean(obj);
            RuleResult result = ruleResultBuilder.Build(rule, input);

            return(result);
        }
Beispiel #2
0
        public RuleResult Build(Rule rule, IDictionary <string, object> input)
        {
            RuleResult result = new RuleResult()
            {
                RuleInput = input, Rule = rule, Success = rule.Success
            };

            try
            {
                result.Message = expressionCompile.Compile(result.Success ? rule.SucessMessage : rule.FaildMessage, input).Replace(ExpressionCompiler.MarkChar.ToString(), string.Empty);
            }
            catch (Exception ex)
            {
                result.ExceptionMessage = ex.Message + ex.StackTrace;
            }

            return(result);
        }
Beispiel #3
0
        public string Execute(string expr, IDictionary <string, object> input)
        {
            var result = _expressionCompile.Compile(expr, input);

            return(result);
        }