private void CheckRule(string ruleName, double valueA, Tokens condition, double valueB) { //check the rule var check = CheckDoubleValue(valueA, valueB, condition); var result = new RuleCheckResult() { Entity = null, IsCompliant = check }; _ruleChecks.Add(ruleName, result); if (!check) WriteLine(String.Format("Values don't comply to the rule \"{0}\"", ruleName)); }
public void Add(string rule, RuleCheckResult result) { var res = _results.Where(r => r.Rule == rule); if (res.Any()) res.FirstOrDefault().CheckResults.Add(result); else { var r = new RuleCheckResults() { Rule = rule }; r.CheckResults.Add(result); _results.Add(r); } }
private void CheckRule(string ruleName, Expression condition, IEnumerable<IPersistIfcEntity> elements) { var func = Expression.Lambda<Func<IPersistIfcEntity, bool>>(condition, _input).Compile(); foreach (var item in elements) { //check the rule var check = func(item); var result = new RuleCheckResult() { Entity = item, IsCompliant = check}; _ruleChecks.Add(ruleName, result); if (!check) WriteLine(String.Format("{0} #{1} doesn't comply to the rule \"{2}\"", item.GetType().Name, item.EntityLabel, ruleName)); } }