private IEnumerable<PropertyValidatorResult> GetNestedPropertyValidators(IValidatorDescriptor desc, List<PropertyInfo> propertyInfo, int i)
        {
            if (i == propertyInfo.Count)
                return new List<PropertyValidatorResult>();

            var vals = desc.GetValidatorsForMember(propertyInfo[i].Name);
            var name = desc.GetName(propertyInfo[i].Name);

            var propertyValidators = new List<PropertyValidatorResult>();

            foreach (var inlineval in vals)
            {
                if (i == propertyInfo.Count - 1)
                    propertyValidators.Add(new PropertyValidatorResult(inlineval, name));

                IValidator val = GetValidator(inlineval, null);

                if (val == null)
                    continue;

                var morevals = GetNestedPropertyValidators(val.CreateDescriptor(), propertyInfo, i + 1);
                propertyValidators.AddRange(morevals.Select(x => new PropertyValidatorResult(x.PropertyValidator, x.DisplayName)));
            }

            return propertyValidators;
        }
Example #2
0
        private IEnumerable <PropertyValidatorResult> GetNestedPropertyValidators(IValidatorDescriptor desc, List <PropertyInfo> propertyInfo, int i)
        {
            if (i == propertyInfo.Count)
            {
                return(new List <PropertyValidatorResult>());
            }

            var vals = desc.GetValidatorsForMember(propertyInfo[i].Name);
            var name = desc.GetName(propertyInfo[i].Name);

            var propertyValidators = new List <PropertyValidatorResult>();

            foreach (var inlineval in vals)
            {
                if (i == propertyInfo.Count - 1)
                {
                    propertyValidators.Add(new PropertyValidatorResult(inlineval, name));
                }

                IValidator val = GetValidator(inlineval, null);

                if (val == null)
                {
                    continue;
                }

                var morevals = GetNestedPropertyValidators(val.CreateDescriptor(), propertyInfo, i + 1);
                propertyValidators.AddRange(morevals.Select(x => new PropertyValidatorResult(x.PropertyValidator, x.DisplayName)));
            }

            return(propertyValidators);
        }
        private IEnumerable<PropertyValidatorResult> GetNestedPropertyValidators(IValidatorDescriptor desc, List<PropertyInfo> propertyInfo, int i)
        {
            if (i == propertyInfo.Count)
                return new List<PropertyValidatorResult>();

            var vals = desc.GetValidatorsForMember(propertyInfo[i].Name);
            var name = desc.GetName(propertyInfo[i].Name);

            var propertyValidators = new List<PropertyValidatorResult>();

            foreach (var inlineval in vals)
            {
                var valtype = inlineval.GetType();
                IValidator val = null;
                if (valtype == typeof(ChildCollectionValidatorAdaptor))
                    val = ((ChildCollectionValidatorAdaptor)inlineval).Validator;
                else if (valtype == typeof(ChildValidatorAdaptor))
                    val = ((ChildValidatorAdaptor)inlineval).Validator;

                if (i == propertyInfo.Count - 1)
                    propertyValidators.Add(new PropertyValidatorResult(inlineval, name));

                if (val == null)
                    continue;

                var morevals = GetNestedPropertyValidators(val.CreateDescriptor(), propertyInfo, i + 1);
                propertyValidators.AddRange(morevals.Select(x => new PropertyValidatorResult(x.PropertyValidator, name)));
            }

            return propertyValidators;
        }
        private IEnumerable <PropertyValidatorResult> GetNestedPropertyValidators(IValidatorDescriptor desc, List <PropertyInfo> propertyInfo, int i)
        {
            if (i == propertyInfo.Count)
            {
                return(new List <PropertyValidatorResult>());
            }

            var vals = desc.GetValidatorsForMember(propertyInfo[i].Name);
            var name = desc.GetName(propertyInfo[i].Name);

            var propertyValidators = new List <PropertyValidatorResult>();

            foreach (var inlineval in vals)
            {
                var        valtype = inlineval.GetType();
                IValidator val     = null;
                if (valtype == typeof(ChildCollectionValidatorAdaptor))
                {
                    val = ((ChildCollectionValidatorAdaptor)inlineval).Validator;
                }
                else if (valtype == typeof(ChildValidatorAdaptor))
                {
                    val = ((ChildValidatorAdaptor)inlineval).Validator;
                }

                if (i == propertyInfo.Count - 1)
                {
                    propertyValidators.Add(new PropertyValidatorResult(inlineval, name));
                }

                if (val == null)
                {
                    continue;
                }

                var morevals = GetNestedPropertyValidators(val.CreateDescriptor(), propertyInfo, i + 1);
                propertyValidators.AddRange(morevals.Select(x => new PropertyValidatorResult(x.PropertyValidator, name)));
            }

            return(propertyValidators);
        }