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); }
private static PropertyInfo FindProperty(Type type, string propertyName, Expression[] arguments, BindingFlags flags) { var props = type.GetProperties(flags).Where(x => x.Name.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase)); var members = new List <PropertyInfo>(props).ToArray(); if (members == null || members.Length == 0) { return(null); } PropertyInfo pi; var propertyInfos = members.Map(t => t); var count = FindBestProperty(propertyInfos, arguments, out pi); if (count == 0) { return(null); } if (count > 1) { throw Error.PropertyWithMoreThanOneMatch(propertyName, type); } return(pi); }
private static PropertyInfo FindProperty(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); }