System.Type.GetPropertyImpl C# (CSharp) Method

GetPropertyImpl() protected method

When overridden in a derived class, searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints.
More than one property is found with the specified name and matching the specified binding constraints. is null.-or- is null.-or- One of the elements in is null. is multidimensional.-or- is multidimensional.-or- and do not have the same length. The current type is a , , or .
protected GetPropertyImpl ( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type types, ParameterModifier modifiers ) : PropertyInfo
name string The string containing the name of the property to get.
bindingAttr BindingFlags A bitmask comprised of one or more that specify how the search is conducted.-or- Zero, to return null.
binder Binder An object that defines a set of properties and enables binding, which can involve selection of an overloaded member, coercion of argument types, and invocation of a member through reflection.-or- A null reference (Nothing in Visual Basic), to use the .
returnType Type The return type of the property.
types Type An array of objects representing the number, order, and type of the parameters for the indexed property to get.-or- An empty array of the type (that is, Type[] types = new Type[0]) to get a property that is not indexed.
modifiers ParameterModifier An array of objects representing the attributes associated with the corresponding element in the array. The default binder does not process this parameter.
return PropertyInfo
        protected PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            foreach (var property in properties)
            {
                var anAccessor = property.GetMethod ?? property.SetMethod;

                if (property.Name != name)
                    continue;
                if ((bindingAttr & BindingFlags.NonPublic) != BindingFlags.NonPublic && !anAccessor.IsPublic)
                    continue;
                var parameters = property.GetIndexParametersNoCopy();
                if (types != null && types.Length != parameters.Length)
                    continue;
                if (types != null)
                {
                    bool isValid = true;
                    for (var i = 0; i < types.Length; i++)
                        if (types[i] != parameters[i].ParameterType)
                            isValid = false;
                    if (!isValid)
                        continue;
                }
                return property;
            }
            return null;
        }