/// <summary> /// Gets the validators. /// </summary> /// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TProperty">The type of the property.</typeparam> /// <param name="runner">The runner.</param> /// <param name="propertyExpression">The property expression.</param> /// <returns></returns> public static IEnumerable <ValidationAttribute> GetValidators <TModel, TProperty>( this IValidationRunner runner, Expression <Func <TModel, TProperty> > propertyExpression) { MemberExpression memberExpression = (MemberExpression)propertyExpression.Body; return(runner.GetValidators(typeof(TProperty), memberExpression.Member.Name)); }
/// <summary> /// Gets the validation attributes. /// </summary> /// <returns></returns> private IEnumerable <ValidationAttribute> GetValidationAttributes() { if (_validationAttributes == null) { _validationAttributes = _validationRunner.GetValidators(GetModelType(), PropertyName); } return(_validationAttributes); }