示例#1
0
        /// <summary>
        /// Create the validator for the children, who got the <see cref="ValidAttribute"/>
        /// on the fields or properties
        /// </summary>
        private void CreateChildValidator(MemberInfo member, IEnumerable <Attribute> memberAttributes)
        {
            if (memberAttributes.OfType <ValidAttribute>().FirstOrDefault() == null)
            {
                return;
            }

            KeyValuePair <System.Type, System.Type> clazzDictionary;

            System.Type clazz;

            childGetters.Add(member);

            if (TypeUtils.IsGenericDictionary(TypeUtils.GetType(member)))
            {
                clazzDictionary = TypeUtils.GetGenericTypesOfDictionary(member);
                if (clazzDictionary.Key.ShouldNeedValidation() && !childClassValidators.ContainsKey(clazzDictionary.Key))
                {
                    factory.GetChildValidator(this, clazzDictionary.Key);
                }
                if (clazzDictionary.Value.ShouldNeedValidation() && !childClassValidators.ContainsKey(clazzDictionary.Value))
                {
                    factory.GetChildValidator(this, clazzDictionary.Value);
                }

                return;
            }
            else
            {
                clazz = TypeUtils.GetTypeOfMember(member);
            }

            if (clazz.ShouldNeedValidation() && !childClassValidators.ContainsKey(clazz))
            {
                factory.GetChildValidator(this, clazz);
            }
        }