public IEnumerable <ValidationAttribute> FindAttributeValidators(RequestData requestData)
        {
            if (requestData.InputType == null)
            {
                return(new List <ValidationAttribute>());
            }

            var properties = InputPropertyMatcher.FindPropertyData(requestData);

            return(properties.SelectMany(propertyInfo => propertyInfo.GetAllAttributes <ValidationAttribute>()));
        }
        public IEnumerable <PropertyValidatorResult> FindValidators(RequestData requestData)
        {
            if (requestData.InputType == null)
            {
                return(new List <PropertyValidatorResult>());
            }

            var baseValidator = ResolveValidator(requestData.InputType);

            if (baseValidator == null)
            {
                return(new List <PropertyValidatorResult>());
            }

            var properties = InputPropertyMatcher.FindPropertyData(requestData);
            var validators = GetPropertyValidators(baseValidator, properties);

            return(validators);
        }
Example #3
0
        private IEnumerable <string> GetPropertyNames()
        {
            var getters          = Accessor.Getters().ToList();
            var aliasModelBinder = (ModelBinders.Binders.DefaultBinder as AliasModelBinder);

            if (InputType != null && aliasModelBinder != null)
            {
                var props = InputPropertyMatcher.FindPropertyData(this);
                var i     = 0;
                return(getters.Select(x =>
                {
                    if (i > props.Count - 1)
                    {
                        return x.Name;
                    }

                    var getter = x as PropertyValueGetter;
                    var prop = props[i];
                    if (getter != null && getter.Name == prop.Name)
                    {
                        i++;
                        var alias = prop.GetAttribute <BindAliasAttribute>();
                        return alias != null ? alias.Alias : x.Name;
                    }
                    return x.Name;
                }));
            }

            return(getters.Select(x =>
            {
                var getter = x as PropertyValueGetter;
                if (getter != null && aliasModelBinder != null)
                {
                    var alias = getter.PropertyInfo.GetAttribute <BindAliasAttribute>();
                    return alias != null ? alias.Alias : getter.Name;
                }
                return x.Name;
            }));
        }
Example #4
0
        private IEnumerable <string> GetPropertyNames()
        {
            var getters = Accessor.Getters().ToList();

            if (InputType != null)
            {
                var props = InputPropertyMatcher.FindPropertyData(this);
                var i     = 0;
                return(getters.Select(x =>
                {
                    if (i > props.Count - 1)
                    {
                        return x.Name;
                    }

                    var getter = x as PropertyValueGetter;
                    var prop = props[i];
                    if (getter != null && getter.Name == prop.Name)
                    {
                        i++;
                        var alias = prop.GetCustomAttribute(typeof(FromQueryAttribute)) as FromQueryAttribute;
                        return alias != null ? alias.Name : x.Name;
                    }
                    return x.Name;
                }));
            }

            return(getters.Select(x =>
            {
                var getter = x as PropertyValueGetter;
                if (getter != null)
                {
                    var alias = getter.PropertyInfo.GetCustomAttribute(typeof(FromQueryAttribute)) as FromQueryAttribute;
                    return alias != null ? alias.Name : getter.Name;
                }
                return x.Name;
            }));
        }