protected override Expression VisitMember(MemberExpression m)
{
if (!this.isInProjection)
{
if (m.Member.MemberType == MemberTypes.Property)
{
PropertyDescriptor pd = TypeDescriptor.GetProperties(m.Member.DeclaringType)[m.Member.Name];
// Let properties for which no PropertyDescriptors exist go through. This happens when we
// deal with structs.
bool requiresValidation = !(pd == null && m.Member.DeclaringType.IsValueType);
if (requiresValidation && !this.IsVisible(pd))
{
if (!PostProcessor.IsProjectionPath(m))
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.UnknownPropertyOrField, pd.Name, ExpressionParser.GetTypeName(pd.ComponentType)));
}
else
{
this.isInProjection = true;
Expression expr = base.VisitMember(m);
this.isInProjection = false;
return(expr);
}
}
}
}
return(base.VisitMember(m));
}