Esempio n. 1
0
 internal static Validator GetPropertyValidator(Type type,
                                                PropertyInfo propertyInfo,
                                                string ruleset,
                                                ValidationSpecificationSource validationSpecificationSource,
                                                MemberValueAccessBuilder memberValueAccessBuilder)
 {
     return(GetPropertyValidator(type,
                                 propertyInfo,
                                 ruleset,
                                 validationSpecificationSource,
                                 new MemberAccessValidatorBuilderFactory(memberValueAccessBuilder)));
 }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="propertyInfo"></param>
 /// <param name="ruleset"></param>
 /// <param name="validationSpecificationSource"></param>
 /// <param name="memberValueAccessBuilder"></param>
 /// <returns></returns>
 public static Validator GetPropertyValidator(Type type,
                                              PropertyInfo propertyInfo,
                                              string ruleset,
                                              ValidationSpecificationSource validationSpecificationSource,
                                              MemberValueAccessBuilder memberValueAccessBuilder)
 {
     // TODO should pass along validator factory?
     return(GetPropertyValidator(type,
                                 propertyInfo,
                                 ruleset,
                                 validationSpecificationSource,
                                 new MemberAccessValidatorBuilderFactory(memberValueAccessBuilder)));
 }
        protected override Validator DoCreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder)
        {
            PropertyInfo propertyInfo = ownerType.GetProperty(propertyOfRootPath, BindingFlags.Public | BindingFlags.Instance);
            if (propertyInfo == null)
            {
                throw new InvalidOperationException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        "Could not find the property specified for the rootPath",
                        this.propertyOfRootPath,
                        ownerType.FullName));
            }

            return new DirectoryDoesNotExistValidator(memberValueAccessBuilder.GetPropertyValueAccess(propertyInfo), Negated);
        }
        protected override Validator DoCreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder) {
            var fieldValueAccesses = new List<ValueAccess>();

            foreach(var field in fieldsToCompare) {
                var propertyInfo = ValidationReflectionHelper.GetProperty(ownerType, field);

                if(propertyInfo == null) {
                    throw new InvalidOperationException();
                }

                fieldValueAccesses.Add(memberValueAccessBuilder.GetPropertyValueAccess(propertyInfo));
            }

            return new UniqueFieldValueValidator(fieldValueAccesses);
        }
        protected override Validator DoCreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder)
        {
            if (string.IsNullOrEmpty(base.PropertyToCompare))
            {
                throw new ConfigurationErrorsException("The property to compare is null");
            }

            PropertyInfo propertyInfo = ownerType.GetProperty(PropertyToCompare);

            if (propertyInfo == null)
            {
                throw new InvalidOperationException
                    (ownerType.Name + "has errors");
            }

            return new DateDiffCompareValidator
                (memberValueAccessBuilder.GetPropertyValueAccess(propertyInfo),
                base.ComparisonOperator,
                DateDiff);
        }
 public Validator CreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder, ValidatorFactory ignored)
 {
     return(new ValidationAttributeValidator(this.attributes));
 }
 public Validator CreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder, ValidatorFactory ignored)
 {
     return new ValidationAttributeValidator(this.attributes);
 }
 public MemberAccessValidatorBuilderFactory(MemberValueAccessBuilder valueAccessBuilder)
 {
     this.valueAccessBuilder = valueAccessBuilder;
 }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="valueAccessBuilder"></param>
 public MemberAccessValidatorBuilderFactory(MemberValueAccessBuilder valueAccessBuilder)
 {
     this.valueAccessBuilder = valueAccessBuilder;
 }
 protected override Validator DoCreateValidator(Type targetType, Type ownerType, MemberValueAccessBuilder memberValueAccessBuilder)
 {
     return new NumericRangeValidator(lowerBound, lowerBoundType,
         upperBound, upperBoundType, maxLength, mandatoryMessageTemplate,
         invalidMessageTemplate, rangeMessageTemplate, maxLengthMessageTemplate);
 }