System.Attribute.GetParentDefinition C# (CSharp) Méthode

GetParentDefinition() private static méthode

private static GetParentDefinition ( PropertyInfo property ) : PropertyInfo
property PropertyInfo
Résultat PropertyInfo
        private static PropertyInfo GetParentDefinition(PropertyInfo property)
        {
            // for the current property get the base class of the getter and the setter, they might be different
            MethodInfo propAccessor = property.GetGetMethod(true); 

            if (propAccessor == null) 
                propAccessor = property.GetSetMethod(true);

            if (propAccessor != null)
            {
                propAccessor = propAccessor.GetParentDefinition();

                if (propAccessor != null)
                    return propAccessor.DeclaringType.GetProperty(property.Name, property.PropertyType);
            }

            return null;
        }

Same methods

Attribute::GetParentDefinition ( EventInfo ev ) : EventInfo

Usage Example

Exemple #1
0
 private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
 {
     if (element.IsDefined(attributeType, inherit))
     {
         return(true);
     }
     if (inherit && Attribute.InternalGetAttributeUsage(attributeType).Inherited)
     {
         for (PropertyInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != (PropertyInfo)null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
         {
             if (parentDefinition.IsDefined(attributeType, false))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
All Usage Examples Of System.Attribute::GetParentDefinition