private static PropertyInfo FindInstanceProperty(Type type, string propertyName, Expression[] arguments)
{
// bind to public names first
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy;
PropertyInfo pi = FindProperty(type, propertyName, arguments, flags);
if (pi == null)
{
flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy;
pi = FindProperty(type, propertyName, arguments, flags);
}
if (pi == null)
{
if (arguments == null || arguments.Length == 0)
{
throw Error.InstancePropertyWithoutParameterNotDefinedForType(propertyName, type);
}
else
{
throw Error.InstancePropertyWithSpecifiedParametersNotDefinedForType(propertyName, GetArgTypesString(arguments), type);
}
}
return pi;
}