private static PropertyInfo?FindProperty(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)] Type type,
string propertyName,
Expression[]?arguments,
BindingFlags flags)
{
PropertyInfo?property = null;
foreach (PropertyInfo pi in type.GetProperties(flags))
{
if (pi.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase) && IsCompatible(pi, arguments))
{
if (property == null)
{
property = pi;
}
else
{
throw Error.PropertyWithMoreThanOneMatch(propertyName, type);
}
}
}
return(property);
}