private static async Task <ValidationResult> ValidateInternal <T>(IValidationRuleSet <T> ruleSet, T instance, ValidationContext context) { var validationMap = new Dictionary <RuleIdentity, ValidationResult>(); var result = new ValidationResult(); var chain = ruleSet.GetValidationChain(); try { foreach (var validationChainMember in chain) { if (await CheckDependsOnMembers(chain, instance, validationChainMember, validationMap, result, context)) { await ProcessRule(instance, validationChainMember, validationMap, result, context); } } } catch (AggregateException ex) when(ex.InnerException is ValidationStoppedException valException) { result.MergeResult(valException.Result); } catch (ValidationStoppedException ex) { result.MergeResult(ex.Result); } return(result); }
private static ValidationResult ValidateInternal <T>(IValidationRuleSet <T> ruleSet, T instance, ValidationContext context) { var validationMap = new Dictionary <RuleIdentity, ValidationResult>(); var result = new ValidationResult(); var chain = ruleSet.GetValidationChain(); try { foreach (var validationChainMember in chain.Where(validationChainMember => CheckDependsOnMembers(chain, instance, validationChainMember, validationMap, result, context))) { ProcessRule(instance, validationChainMember, validationMap, result, context); } } catch (ValidationStoppedException e) { result.MergeResult(e.Result); } return(result); }