Hi Jimmy,
To build our views we're using strongly typed helpers that accept
lambda expressions for Dto properties. For example we have the
following model:
public class Person
{
[ValidateNonEmpty]
public string FirstName {get;set;}
}
public class PersonDto : IDto<Person>
{
public string FirstName {get;set;}
}
In the view the helper looks like this:
Html<PersonDto>.TextboxWitValidationFor(p => p.FirstName)
So our helper needs somehow to access original properties to get
original validation attributes. From IDto<> interface we know original
type, but we don't know from which property validation definition
should be taken. I've already implemented this via reflection:
IValueResolver modelPropertyAccessor = GetModelPropertyAccessor
(dtoType, dtoPropertyName);
return ReflectionHelper
.GetFieldValue<PropertyInfo>(modelPropertyAccessor, "_propertyInfo")
.GetCustomAttributes(typeof(AbstractValidationAttribute), true)
.Cast<AbstractValidationAttribute>();
But having this in API seems to be more natural, so i've provided a
patch.
Hopefully it makes sense
On Oct 19, 1:40 am, Jimmy Bogard <
jimmy.bog...@gmail.com> wrote:
> Hi Vitalya,
>
> It looks interesting, but I can't figure out what adding this information to
> the IMemberGetter will do for anyone. How would this help with the
> Castle.Validator issue?
>