Exemplo n.º 1
0
 public PropertyCheckContext(CheckContext <T> parentContext, PropertyRule <T, TProperty> rule, string propertyName)
 {
     ParentContext          = parentContext;
     Rule                   = rule;
     PropertyName           = propertyName;
     propertyValueContainer = new Lazy <TProperty>(() => rule.PropertyFunc(parentContext.InstanceToCheck));
 }
Exemplo n.º 2
0
        public IEnumerable <CheckFailure> Check(CheckContext <T> context)
        {
            foreach (var checker in checkers)
            {
                var hasFailure = false;
                var failures   = checker.Checker(new PropertyCheckContext <T, TProperty>(context, this, Member.Name));

                foreach (var item in failures)
                {
                    hasFailure = true;
                    yield return(item);
                }

                if (hasFailure)
                {
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public virtual CheckResult Check(CheckContext <T> context)
        {
            var failures = rules.SelectMany(r => r.Check(context));

            return(new CheckResult(failures));
        }