Прочетете на английски Редактиране

Споделяне чрез


CustomAttributeExtensions.IsDefined Method

Definition

Indicates whether custom attributes are applied to an element.

Overloads

IsDefined(MemberInfo, Type, Boolean)

Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.

IsDefined(Assembly, Type)

Indicates whether custom attributes of a specified type are applied to a specified assembly.

IsDefined(MemberInfo, Type)

Indicates whether custom attributes of a specified type are applied to a specified member.

IsDefined(Module, Type)

Indicates whether custom attributes of a specified type are applied to a specified module.

IsDefined(ParameterInfo, Type)

Indicates whether custom attributes of a specified type are applied to a specified parameter.

IsDefined(ParameterInfo, Type, Boolean)

Indicates whether custom attributes of a specified type are applied to a specified parameter, and, optionally, applied to its ancestors.

IsDefined(MemberInfo, Type, Boolean)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.

C#
public static bool IsDefined(this System.Reflection.MemberInfo element, Type attributeType, bool inherit);

Parameters

element
MemberInfo

The member to inspect.

attributeType
Type

The type of the attribute to search for.

inherit
Boolean

true to inspect the ancestors of element; otherwise, false.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

element is not a constructor, method, property, event, type, or field.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

IsDefined(Assembly, Type)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified assembly.

C#
public static bool IsDefined(this System.Reflection.Assembly element, Type attributeType);

Parameters

element
Assembly

The assembly to inspect.

attributeType
Type

The type of the attribute to search for.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

IsDefined(MemberInfo, Type)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified member.

C#
public static bool IsDefined(this System.Reflection.MemberInfo element, Type attributeType);

Parameters

element
MemberInfo

The member to inspect.

attributeType
Type

The type of attribute to search for.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

element is not a constructor, method, property, event, type, or field.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

IsDefined(Module, Type)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified module.

C#
public static bool IsDefined(this System.Reflection.Module element, Type attributeType);

Parameters

element
Module

The module to inspect.

attributeType
Type

The type of attribute to search for.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

IsDefined(ParameterInfo, Type)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified parameter.

C#
public static bool IsDefined(this System.Reflection.ParameterInfo element, Type attributeType);

Parameters

element
ParameterInfo

The parameter to inspect.

attributeType
Type

The type of attribute to search for.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

IsDefined(ParameterInfo, Type, Boolean)

Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs
Source:
CustomAttributeExtensions.cs

Indicates whether custom attributes of a specified type are applied to a specified parameter, and, optionally, applied to its ancestors.

C#
public static bool IsDefined(this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);

Parameters

element
ParameterInfo

The parameter to inspect.

attributeType
Type

The type of attribute to search for.

inherit
Boolean

true to inspect the ancestors of element; otherwise, false.

Returns

true if an attribute of the specified type is applied to element; otherwise, false.

Exceptions

element or attributeType is null.

attributeType is not derived from Attribute.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0