Method GetAttribute
- Namespace
- Ploch.CommandLine.Spectre.Commands
- Assembly
- Ploch.CommandLine.Spectre.dll
GetAttribute<TAttribute>(PropertyInfo, bool)
Retrieves a required attribute from a property.
protected static TAttribute GetAttribute<TAttribute>(PropertyInfo property, bool inherit = true) where TAttribute : Attribute
Parameters
propertyPropertyInfoThe property to read the attribute from.
inheritboolWhether to search the property's inheritance chain. Defaults to true.
Returns
- TAttribute
The attribute found on the property.
Type Parameters
TAttributeThe attribute type to retrieve.
Exceptions
- ArgumentNullException
Thrown when the attribute is not present on the property.