Table of Contents

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

property PropertyInfo

The property to read the attribute from.

inherit bool

Whether to search the property's inheritance chain. Defaults to true.

Returns

TAttribute

The attribute found on the property.

Type Parameters

TAttribute

The attribute type to retrieve.

Exceptions

ArgumentNullException

Thrown when the attribute is not present on the property.