CustomAttributeExtensions Class

Provides extension methods for checking custom attributes on reflection types.

public static class CustomAttributeExtensions

Methods

NameDescription
HasCustomAttribute(Assembly, Type)Determines whether a custom attribute of the specified type is applied to the assembly.
HasCustomAttribute(Assembly, Type, bool)Determines whether a custom attribute of the specified type is applied to the assembly.
HasCustomAttribute(MemberInfo, Type)Determines whether a custom attribute of the specified type is applied to the member.
HasCustomAttribute(MemberInfo, Type, bool)Determines whether a custom attribute of the specified type is applied to the member.
HasCustomAttribute(Module, Type)Determines whether a custom attribute of the specified type is applied to the module.
HasCustomAttribute(Module, Type, bool)Determines whether a custom attribute of the specified type is applied to the module.
HasCustomAttribute(ParameterInfo, Type)Determines whether a custom attribute of the specified type is applied to the parameter.
HasCustomAttribute(ParameterInfo, Type, bool)Determines whether a custom attribute of the specified type is applied to the parameter.
HasCustomAttribute(Type, Type)Determines whether a custom attribute of the specified type is applied to the type.
HasCustomAttribute(Type, Type, bool)Determines whether a custom attribute of the specified type is applied to the type.
HasCustomAttribute<T>(Assembly)Determines whether a custom attribute of the specified type is applied to the assembly.
HasCustomAttribute<T>(Assembly, bool)Determines whether a custom attribute of the specified type is applied to the assembly.
HasCustomAttribute<T>(MemberInfo)Determines whether a custom attribute of the specified type is applied to the member.
HasCustomAttribute<T>(MemberInfo, bool)Determines whether a custom attribute of the specified type is applied to the member.
HasCustomAttribute<T>(Module)Determines whether a custom attribute of the specified type is applied to the module.
HasCustomAttribute<T>(Module, bool)Determines whether a custom attribute of the specified type is applied to the module.
HasCustomAttribute<T>(ParameterInfo)Determines whether a custom attribute of the specified type is applied to the parameter.
HasCustomAttribute<T>(ParameterInfo, bool)Determines whether a custom attribute of the specified type is applied to the parameter.
HasCustomAttribute<T>(Type)Determines whether a custom attribute of the specified type is applied to the type.
HasCustomAttribute<T>(Type, bool)Determines whether a custom attribute of the specified type is applied to the type.

HasCustomAttribute overloads

HasCustomAttribute(Assembly, Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the assembly.

public static bool HasCustomAttribute(this Assembly assembly, Type attributeType)
Parameters
assembly Assembly
The assembly to check.
attributeType Type
The type of attribute to search for.
Returns

bool true if the attribute is applied to the assembly; otherwise, false.

HasCustomAttribute(Assembly, Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the assembly.

public static bool HasCustomAttribute(this Assembly assembly, Type attributeType, bool inherit)
Parameters
assembly Assembly
The assembly to check.
attributeType Type
The type of attribute to search for.
inherit bool
This parameter is ignored for assemblies.
Returns

bool true if the attribute is applied to the assembly; otherwise, false.

HasCustomAttribute(MemberInfo, Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the member.

public static bool HasCustomAttribute(this MemberInfo member, Type attributeType)
Parameters
member MemberInfo
The member to check.
attributeType Type
The type of attribute to search for.
Returns

bool true if the attribute is applied to the member; otherwise, false.

HasCustomAttribute(MemberInfo, Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the member.

public static bool HasCustomAttribute(this MemberInfo member, Type attributeType, bool inherit)
Parameters
member MemberInfo
The member to check.
attributeType Type
The type of attribute to search for.
inherit bool
true to search the member's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the member; otherwise, false.

HasCustomAttribute(Module, Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the module.

public static bool HasCustomAttribute(this Module module, Type attributeType)
Parameters
module Module
The module to check.
attributeType Type
The type of attribute to search for.
Returns

bool true if the attribute is applied to the module; otherwise, false.

HasCustomAttribute(Module, Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the module.

public static bool HasCustomAttribute(this Module module, Type attributeType, bool inherit)
Parameters
module Module
The module to check.
attributeType Type
The type of attribute to search for.
inherit bool
This parameter is ignored for modules.
Returns

bool true if the attribute is applied to the module; otherwise, false.

HasCustomAttribute(ParameterInfo, Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the parameter.

public static bool HasCustomAttribute(this ParameterInfo parameter, Type attributeType)
Parameters
parameter ParameterInfo
The parameter to check.
attributeType Type
The type of attribute to search for.
Returns

bool true if the attribute is applied to the parameter; otherwise, false.

HasCustomAttribute(ParameterInfo, Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the parameter.

public static bool HasCustomAttribute(this ParameterInfo parameter, Type attributeType, bool inherit)
Parameters
parameter ParameterInfo
The parameter to check.
attributeType Type
The type of attribute to search for.
inherit bool
true to search the parameter's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the parameter; otherwise, false.

HasCustomAttribute(Type, Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the type.

public static bool HasCustomAttribute(this Type type, Type attributeType)
Parameters
type Type
The type to check.
attributeType Type
The type of attribute to search for.
Returns

bool true if the attribute is applied to the type; otherwise, false.

HasCustomAttribute(Type, Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the type.

public static bool HasCustomAttribute(this Type type, Type attributeType, bool inherit)
Parameters
type Type
The type to check.
attributeType Type
The type of attribute to search for.
inherit bool
true to search the type's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the type; otherwise, false.

HasCustomAttribute<T>(Assembly)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the assembly.

public static bool HasCustomAttribute<T>(this Assembly assembly) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
assembly Assembly
The assembly to check.
Returns

bool true if the attribute is applied to the assembly; otherwise, false.

HasCustomAttribute<T>(Assembly, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the assembly.

public static bool HasCustomAttribute<T>(this Assembly assembly, bool inherit) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
assembly Assembly
The assembly to check.
inherit bool
This parameter is ignored for assemblies.
Returns

bool true if the attribute is applied to the assembly; otherwise, false.

HasCustomAttribute<T>(MemberInfo)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the member.

public static bool HasCustomAttribute<T>(this MemberInfo member) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
member MemberInfo
The member to check.
Returns

bool true if the attribute is applied to the member; otherwise, false.

HasCustomAttribute<T>(MemberInfo, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the member.

public static bool HasCustomAttribute<T>(this MemberInfo member, bool inherit) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
member MemberInfo
The member to check.
inherit bool
true to search the member's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the member; otherwise, false.

HasCustomAttribute<T>(Module)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the module.

public static bool HasCustomAttribute<T>(this Module module) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
module Module
The module to check.
Returns

bool true if the attribute is applied to the module; otherwise, false.

HasCustomAttribute<T>(Module, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the module.

public static bool HasCustomAttribute<T>(this Module module, bool inherit) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
module Module
The module to check.
inherit bool
This parameter is ignored for modules.
Returns

bool true if the attribute is applied to the module; otherwise, false.

HasCustomAttribute<T>(ParameterInfo)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the parameter.

public static bool HasCustomAttribute<T>(this ParameterInfo parameter) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
parameter ParameterInfo
The parameter to check.
Returns

bool true if the attribute is applied to the parameter; otherwise, false.

HasCustomAttribute<T>(ParameterInfo, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the parameter.

public static bool HasCustomAttribute<T>(this ParameterInfo parameter, bool inherit) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
parameter ParameterInfo
The parameter to check.
inherit bool
true to search the parameter's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the parameter; otherwise, false.

HasCustomAttribute<T>(Type)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the type.

public static bool HasCustomAttribute<T>(this Type type) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
type Type
The type to check.
Returns

bool true if the attribute is applied to the type; otherwise, false.

HasCustomAttribute<T>(Type, bool)

CustomAttributeExtensions.cs

Determines whether a custom attribute of the specified type is applied to the type.

public static bool HasCustomAttribute<T>(this Type type, bool inherit) where T : Attribute
Type parameters
T
The type of attribute to search for.
Parameters
type Type
The type to check.
inherit bool
true to search the type's inheritance chain to find the attributes; otherwise, false.
Returns

bool true if the attribute is applied to the type; otherwise, false.