Lire en anglais

Partager via


ICustomAttributeProvider.GetCustomAttributes Méthode

Définition

Retourne les attributs personnalisés définis sur ce membre.

Surcharges

GetCustomAttributes(Boolean)

Retourne un tableau de tous les attributs personnalisés définis sur ce membre, en dehors des attributs nommés, ou un tableau vide s’il n’y a aucun attribut personnalisé.

GetCustomAttributes(Type, Boolean)

Retourne un tableau d’attributs personnalisés définis sur ce membre, identifiés par type, ou un tableau vide s’il n’y a aucun attribut personnalisé de ce type.

GetCustomAttributes(Boolean)

Retourne un tableau de tous les attributs personnalisés définis sur ce membre, en dehors des attributs nommés, ou un tableau vide s’il n’y a aucun attribut personnalisé.

C#
public object[] GetCustomAttributes(bool inherit);

Paramètres

inherit
Boolean

Si true, recherchez la chaîne de hiérarchie pour l’attribut personnalisé hérité.

Retours

Object[]

Un tableau d’objets représentant des attributs personnalisés ou un tableau vide.

Exceptions

Le type d’attribut personnalisé ne peut pas être chargé.

Il existe plusieurs attributs de type attributeType définis sur ce membre.

Remarques

L’appel ICustomAttributeProvider.GetCustomAttributes sur PropertyInfo ou EventInfo lorsque le inherit paramètre de GetCustomAttributes est true ne marche pas dans la hiérarchie de type. Utilisez System.Attribute pour hériter d’attributs personnalisés.

Cette méthode retourne des attributs personnalisés définis directement sur un membre non hérité uniquement.

S’applique à

.NET 10 et autres versions
Produit Versions
.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 1.1, 2.0, 3.0, 3.5, 4.0, 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.5, 1.6, 2.0, 2.1

GetCustomAttributes(Type, Boolean)

Retourne un tableau d’attributs personnalisés définis sur ce membre, identifiés par type, ou un tableau vide s’il n’y a aucun attribut personnalisé de ce type.

C#
public object[] GetCustomAttributes(Type attributeType, bool inherit);

Paramètres

attributeType
Type

Type des attributs personnalisés.

inherit
Boolean

Si true, recherchez la chaîne de hiérarchie pour l’attribut personnalisé hérité.

Retours

Object[]

Un tableau d’objets représentant des attributs personnalisés ou un tableau vide.

Exceptions

Le type d’attribut personnalisé ne peut pas être chargé.

attributeType a la valeur null.

Remarques

Si attributeType est une classe ou une interface de base, cette méthode retourne toute implémentation de ce type.

Cette méthode retourne des attributs personnalisés définis directement sur un membre non hérité uniquement.

L’appel ICustomAttributeProvider.GetCustomAttributes sur PropertyInfo ou EventInfo lorsque le inherit paramètre de GetCustomAttributes est true ne marche pas dans la hiérarchie de type. Utilisez System.Attribute pour hériter d’attributs personnalisés.

S’applique à

.NET 10 et autres versions
Produit Versions
.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 1.1, 2.0, 3.0, 3.5, 4.0, 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.5, 1.6, 2.0, 2.1