Exemple #1
0
        protected override RuleExecutionResult Validate(TInstance instance)
        {
            TValue value;
            var    result = new RuleExecutionResult();

            // Not sure about that...
            if (TryGetValue(instance, out value))
            {
                var valid = validator.Validate(instance, GetValue(instance));
                if (!valid)
                {
                    result.BrokenRules.Add(new BrokenRule(this, instance, propertyKey, propertyName, value));
                }
            }

            return(result);
        }
Exemple #2
0
        protected override RuleExecutionResult Validate(TInstance instance)
        {
            var ruleset = new RuleSet(typeof(TItem), Rules.Cast <IRule>());
            var items   = GetValue(instance);
            var result  = new RuleExecutionResult();

            foreach (var i in items)
            {
                var r = ruleset.Validate(i);

                foreach (var br in r.BrokenRules)
                {
                    result.BrokenRules.Add(br);
                }

                if (r.StopEvaluation)
                {
                    result.StopEvaluation = true;
                    break;
                }
            }

            return(result);
        }