Beispiel #1
0
        public Validator CreateValidatorForProperty(Type type, ValidatedPropertyReference propertyReference)
        {
            if (propertyReference.Validators.Count == 0)
            {
                return(null);
            }

            PropertyInfo propertyInfo = ValidationReflectionHelper.GetProperty(type, propertyReference.Name, false);

            if (propertyInfo == null)
            {
                return(null);
            }

            ConfigurationValidatedElement validatedElement = new ConfigurationValidatedElement(propertyReference, propertyInfo);

            return(CreateValidatorForValidatedElement(validatedElement, this.GetCompositeValidatorBuilderForProperty));
        }
        IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties()
        {
            ConfigurationValidatedElement flyweight = new ConfigurationValidatedElement();

            foreach (ValidatedPropertyReference validatedMemberReference in this.ruleData.Properties)
            {
                if (validatedMemberReference.Validators.Count == 0)
                {
                    continue;
                }

                PropertyInfo propertyInfo
                    = ValidationReflectionHelper.GetProperty(this.targetType, validatedMemberReference.Name, false);
                if (propertyInfo == null)
                {
                    continue;
                }

                flyweight.UpdateFlyweight(validatedMemberReference, propertyInfo);
                yield return(flyweight);
            }
        }