public static Validator CreateValidator(ParameterInfo paramInfo) { MetadataValidatedParameterElement metadataValidatedParameterElement = new MetadataValidatedParameterElement(); metadataValidatedParameterElement.UpdateFlyweight(paramInfo); CompositeValidatorBuilder compositeValidatorBuilder = new CompositeValidatorBuilder(metadataValidatedParameterElement); foreach (IValidatorDescriptor current in metadataValidatedParameterElement.GetValidatorDescriptors()) { compositeValidatorBuilder.AddValueValidator(current.CreateValidator(paramInfo.ParameterType, null, null)); } return(compositeValidatorBuilder.GetValidator()); }
protected Validator CreateValidatorForValidatedElement(IValidatedElement validatedElement, ValidatorBuilderBase.CompositeValidatorBuilderCreator validatorBuilderCreator) { IEnumerator <IValidatorDescriptor> enumerator = validatedElement.GetValidatorDescriptors().GetEnumerator(); if (!enumerator.MoveNext()) { return(null); } CompositeValidatorBuilder compositeValidatorBuilder = validatorBuilderCreator(validatedElement); do { Validator valueValidator = enumerator.Current.CreateValidator(validatedElement.TargetType, validatedElement.MemberInfo.ReflectedType, this.memberAccessValidatorFactory.MemberValueAccessBuilder); compositeValidatorBuilder.AddValueValidator(valueValidator); }while (enumerator.MoveNext()); return(compositeValidatorBuilder.GetValidator()); }