PostSharpAPI ReferencePost­Sharp.​ReflectionReflection­SearchHas­Custom­Attribute
Open sandboxFocus

ReflectionSearch.HasCustomAttribute Method

HasCustomAttribute(Object, Type, Boolean)

Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.

Declaration
public static bool HasCustomAttribute(object target, Type type, bool inherit = false)
Parameters
Type Name Description
Object target

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

System.Type type

The type of custom attributes.

Boolean inherit

true to consider custom attributes derived from type, false to consider only custom attributes strictly of type type.

Returns
Type Description
Boolean

True if type has a custom attribute of type type, otherwise false.