net472_PropertyGridHelpers.Support_Support_GetFirstCustomAttribute - dparvin/PropertyGridHelpers GitHub Wiki
Retrieves the first custom attribute of the specified type applied to the given MemberInfo.
public static T GetFirstCustomAttribute<T>(MemberInfo member)
where T : Attribute
parameter | description |
---|---|
T | The type of attribute to retrieve. Must derive from Attribute. |
member | The member (e.g., property, method, field, type) to inspect for the attribute. |
An instance of the attribute type T if one is defined on the member; otherwise, null
.
exception | condition |
---|---|
ArgumentNullException | Thrown if member is null . |
On .NET Framework 3.5, this uses Boolean) internally; on later versions, it uses Boolean).
Example usage:
var property = typeof(MyClass).GetProperty("MyProperty");
var attr = Support.GetFirstCustomAttribute<AutoCompleteSetupAttribute>(property);
if (attr != null)
{
// Attribute was found
}
- class Support
- namespace PropertyGridHelpers.Support
- assembly PropertyGridHelpers