Ejemplo n.º 1
0
        public Validator CreateValidatorForMethod(Type type, ValidatedMethodReference methodReference)
        {
            if (methodReference.Validators.Count == 0)
            {
                return(null);
            }

            MethodInfo methodInfo = ValidationReflectionHelper.GetMethod(type, methodReference.Name, false);

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

            ConfigurationValidatedElement validatedElement = new ConfigurationValidatedElement(methodReference, methodInfo);

            return(CreateValidatorForValidatedElement(validatedElement, this.GetCompositeValidatorBuilderForMethod));
        }
Ejemplo n.º 2
0
        IEnumerable<IValidatedElement> IValidatedType.GetValidatedMethods()
        {
            ConfigurationValidatedElement flyweight = new ConfigurationValidatedElement();

            foreach (ValidatedMethodReference validatedMemberReference in this.ruleData.Methods)
            {
                if (validatedMemberReference.Validators.Count == 0)
                    continue;

                MethodInfo methodInfo
                    = ValidationReflectionHelper.GetMethod(this.targetType, validatedMemberReference.Name, false);
                if (methodInfo == null)
                    continue;

                flyweight.UpdateFlyweight(validatedMemberReference, methodInfo);
                yield return flyweight;
            }
        }
Ejemplo n.º 3
0
        public Validator CreateValidatorForField(Type type, ValidatedFieldReference fieldReference)
        {
            if (fieldReference.Validators.Count == 0)
            {
                return(null);
            }

            FieldInfo fieldInfo = ValidationReflectionHelper.GetField(type, fieldReference.Name, false);

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

            ConfigurationValidatedElement validatedElement = new ConfigurationValidatedElement(fieldReference, fieldInfo);

            return(CreateValidatorForValidatedElement(validatedElement, this.GetCompositeValidatorBuilderForField));
        }
Ejemplo n.º 4
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.GetValidatedMethods()
        {
            ConfigurationValidatedElement flyweight = new ConfigurationValidatedElement();

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

                MethodInfo methodInfo
                    = ValidationReflectionHelper.GetMethod(this.targetType, validatedMemberReference.Name, false);
                if (methodInfo == null)
                {
                    continue;
                }

                flyweight.UpdateFlyweight(validatedMemberReference, methodInfo);
                yield return(flyweight);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This member supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// </summary>
        public Validator CreateValidatorForMethod(Type type, ValidatedMethodReference methodReference)
        {
            if (methodReference == null) throw new ArgumentNullException("methodReference");

            if (methodReference.Validators.Count == 0)
                return null;

            MethodInfo methodInfo = ValidationReflectionHelper.GetMethod(type, methodReference.Name, false);
            if (methodInfo == null)
                return null;

            ConfigurationValidatedElement validatedElement = new ConfigurationValidatedElement(methodReference, methodInfo);

            return CreateValidatorForValidatedElement(validatedElement, this.GetCompositeValidatorBuilderForMethod);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="propertyReference"></param>
        /// <returns></returns>
        public Validator CreateValidatorForProperty(Type type, ValidatedPropertyReference propertyReference)
        {
            if (propertyReference == null) throw new ArgumentNullException("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);
        }