Ejemplo n.º 1
0
        protected virtual PropertyValidator GetValidatorForProperty(
            EntityValidator entityValidator,
            InternalMemberEntry memberEntry)
        {
            InternalNestedPropertyEntry nestedPropertyEntry = memberEntry as InternalNestedPropertyEntry;

            if (nestedPropertyEntry == null)
            {
                return(entityValidator.GetPropertyValidator(memberEntry.Name));
            }
            ComplexPropertyValidator validatorForProperty = this.GetValidatorForProperty(entityValidator, (InternalMemberEntry)nestedPropertyEntry.ParentPropertyEntry) as ComplexPropertyValidator;

            if (validatorForProperty == null || validatorForProperty.ComplexTypeValidator == null)
            {
                return((PropertyValidator)null);
            }
            return(validatorForProperty.ComplexTypeValidator.GetPropertyValidator(memberEntry.Name));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets a validator for the <paramref name="memberEntry" />.
        /// </summary>
        /// <param name="entityValidator"> Entity validator. </param>
        /// <param name="memberEntry"> Property to get a validator for. </param>
        /// <returns>
        ///     Validator to validate <paramref name="memberEntry" /> . Possibly null if there is no validation for the
        ///     <paramref
        ///         name="memberEntry" />
        ///     .
        /// </returns>
        /// <remarks>
        ///     For complex properties this method walks up the type hierarchy to get to the entity level and then goes down
        ///     and gets a validator for the child property that is an ancestor of the property to validate. If a validator
        ///     returned for an ancestor is null it means that there is no validation defined beneath and the method just
        ///     propagates (and eventually returns) null.
        /// </remarks>
        protected virtual PropertyValidator GetValidatorForProperty(
            EntityValidator entityValidator, InternalMemberEntry memberEntry)
        {
            var complexPropertyEntry = memberEntry as InternalNestedPropertyEntry;

            if (complexPropertyEntry != null)
            {
                var propertyValidator =
                    GetValidatorForProperty(entityValidator, complexPropertyEntry.ParentPropertyEntry) as
                    ComplexPropertyValidator;
                // if a validator for parent property is null there is no validation for child properties.
                // just propagate the null.
                return(propertyValidator != null && propertyValidator.ComplexTypeValidator != null
                           ? propertyValidator.ComplexTypeValidator.GetPropertyValidator(memberEntry.Name)
                           : null);
            }
            else
            {
                return(entityValidator.GetPropertyValidator(memberEntry.Name));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Gets a validator for the <paramref name="memberEntry" />.
 /// </summary>
 /// <param name="entityValidator"> Entity validator. </param>
 /// <param name="memberEntry"> Property to get a validator for. </param>
 /// <returns> Validator to validate <paramref name="memberEntry" /> . Possibly null if there is no validation for the <paramref
 ///      name="memberEntry" /> . </returns>
 /// <remarks>
 ///     For complex properties this method walks up the type hierarchy to get to the entity level and then goes down
 ///     and gets a validator for the child property that is an ancestor of the property to validate. If a validator
 ///     returned for an ancestor is null it means that there is no validation defined beneath and the method just 
 ///     propagates (and eventually returns) null.
 /// </remarks>
 protected virtual PropertyValidator GetValidatorForProperty(
     EntityValidator entityValidator, InternalMemberEntry memberEntry)
 {
     var complexPropertyEntry = memberEntry as InternalNestedPropertyEntry;
     if (complexPropertyEntry != null)
     {
         var propertyValidator =
             GetValidatorForProperty(entityValidator, complexPropertyEntry.ParentPropertyEntry) as
             ComplexPropertyValidator;
         // if a validator for parent property is null there is no validation for child properties.  
         // just propagate the null.
         return propertyValidator != null && propertyValidator.ComplexTypeValidator != null
                    ? propertyValidator.ComplexTypeValidator.GetPropertyValidator(memberEntry.Name)
                    : null;
     }
     else
     {
         return entityValidator.GetPropertyValidator(memberEntry.Name);
     }
 }