PostSharpAPI ReferencePost­Sharp.​ReflectionReflection­SearchGet­Custom­Attributes­On­Target
Open sandboxFocus

Method GetCustomAttributesOnTarget

GetCustomAttributesOnTarget(Object)

Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.

Declaration
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(object target)
Parameters
Type Name Description
Object target

Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

Returns
Type Description
CustomAttributeInstance[]

The set of all custom attributes added, directly or indirectly, to target.

GetCustomAttributesOnTarget(Object, ReflectionSearchOptions)

Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.

Declaration
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(object target, ReflectionSearchOptions options)
Parameters
Type Name Description
Object target

Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

ReflectionSearchOptions options

This parameter has no effect and is kept only for backwards compatibility.

Returns
Type Description
CustomAttributeInstance[]

The set of all custom attributes added, directly or indirectly, to target.

GetCustomAttributesOnTarget<T>(Object, ReflectionSearchOptions)

Gets all custom attributes of a given type on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.

Declaration
public static IList<T> GetCustomAttributesOnTarget<T>(object target, ReflectionSearchOptions options)
where T : Attribute
Parameters
Type Name Description
Object target

Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

ReflectionSearchOptions options

IncludeDerivedTypes or None.

Returns
Type Description
IList<T>

The set of all custom attributes added, directly or indirectly, to target.

Type Parameters
Name Description
T

Type of the custom attribute.