GetCustomAttributesOnTarget(object)
Gets all custom attributes on a given element of code, including those that have been added indirectly, for instance through MulticastAttribute.
Declaration
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(object target)Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The element of code (Type, MethodInfo, and so on) whose custom attributes are requested. |
Returns
| Type | Description |
|---|---|
| CustomAttributeInstance[] | The set of all custom attributes added, directly or indirectly, to |
Remarks
note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .
note
This feature is available only at build time.
GetCustomAttributesOnTarget(object, ReflectionSearchOptions)
Gets all custom attributes on a given element of code, including those that have been added indirectly, for instance through MulticastAttribute.
Declaration
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(object target, ReflectionSearchOptions options)Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The element of code (Type, MethodInfo, and so on) 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 |
Remarks
note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .
note
This feature is available only at build time.
GetCustomAttributesOnTarget<T>(object, ReflectionSearchOptions)
Gets all custom attributes of a given type on a given element of code, including those that have been added indirectly, for instance through MulticastAttribute and specifies additional options.
Declaration
public static IList<T> GetCustomAttributesOnTarget<T>(object target, ReflectionSearchOptions options = ReflectionSearchOptions.IncludeDerivedTypes) where T : AttributeParameters
| Type | Name | Description |
|---|---|---|
| object | target | The element of code (Type, MethodInfo, and so on) whose custom attributes are requested. |
| ReflectionSearchOptions | options | Either IncludeDerivedTypes or None. |
Returns
| Type | Description |
|---|---|
| IList<T> | The set of all custom attributes added, directly or indirectly, to |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the custom attribute. |
Remarks
note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .
note
This feature is available only at build time.