public ActionDataBuilder PreprocessWith(object dataObject)
 {
     _dataObject = dataObject;
     _containerParameterValues = _preprocessor.Process(_containerParameterValues, _dataObject);
     _action.Parameter         = _preprocessor.Process(_action.Parameter, _dataObject);
     return(this);
 }
Beispiel #2
0
        private bool SatisfiesCustomConstraints(AppRule appRule, object dataObject)
        {
            var cv = appRule.RuleConstraints;

            if (string.IsNullOrEmpty(cv))
            {
                return(true);
            }
            cv = _preprocessor.Process(cv, dataObject);
            var cvs = JsonHelper.Deserialize <List <RuleConstraintValue> >(cv);

            if (!cvs.Any())
            {
                return(true);
            }
            switch ((RuleConstraintMatch)appRule.ConstraintMatch)
            {
            case RuleConstraintMatch.MatchesAny: return(cvs.Any(x => x.Satisfies(dataObject)));

            case RuleConstraintMatch.MatchesAll: return(cvs.All(x => x.Satisfies(dataObject)));

            case RuleConstraintMatch.NotMatchesAny: return(cvs.Any(x => !x.Satisfies(dataObject)));

            case RuleConstraintMatch.NotMatchesAll: return(cvs.All(x => !x.Satisfies(dataObject)));

            default: return(cvs.GroupBy(x => x.Left).All(x => x.Any(y => y.Satisfies(dataObject))));
            }
        }
Beispiel #3
0
 public bool Evals(string expression, object dataObject, bool defaultValue)
 {
     if (string.IsNullOrEmpty(expression))
     {
         return(defaultValue);
     }
     expression = _preprocessor.Process(expression, dataObject);
     return(_expressionService.Eval("result = " + expression, dataObject, defaultValue));
 }