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)); }
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; } } }
public virtual CheckResult Check(CheckContext <T> context) { var failures = rules.SelectMany(r => r.Check(context)); return(new CheckResult(failures)); }