CustomAttributeExtensions.GetCustomAttribute Méthode

Définition

Récupère un attribut personnalisé appliqué à un élément spécifié.

Surcharges

GetCustomAttribute(Assembly, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un assembly spécifié.

GetCustomAttribute(MemberInfo, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié.

GetCustomAttribute(Module, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un module spécifié.

GetCustomAttribute(ParameterInfo, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié.

GetCustomAttribute(MemberInfo, Type, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié, et inspecte éventuellement les ancêtres de ce membre.

GetCustomAttribute(ParameterInfo, Type, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié, et inspecte éventuellement les ancêtres de ce paramètre.

GetCustomAttribute<T>(ParameterInfo, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié, et inspecte éventuellement les ancêtres de ce paramètre.

GetCustomAttribute<T>(MemberInfo, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié, et inspecte éventuellement les ancêtres de ce membre.

GetCustomAttribute<T>(ParameterInfo)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié.

GetCustomAttribute<T>(Module)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un module spécifié.

GetCustomAttribute<T>(MemberInfo)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié.

GetCustomAttribute<T>(Assembly)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un assembly spécifié.

GetCustomAttribute(Assembly, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un assembly spécifié.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.Assembly element, Type attributeType);
public static Attribute? GetCustomAttribute (this System.Reflection.Assembly element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Assembly * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Assembly, attributeType As Type) As Attribute

Paramètres

element
Assembly

Assembly à inspecter.

attributeType
Type

Type d’attribut à rechercher.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

Plusieurs attributs demandés ont été trouvés.

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute(MemberInfo, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType);
public static Attribute? GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type) As Attribute

Paramètres

element
MemberInfo

Membre à inspecter.

attributeType
Type

Type d’attribut à rechercher.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute(Module, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un module spécifié.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Module ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.Module element, Type attributeType);
public static Attribute? GetCustomAttribute (this System.Reflection.Module element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Module * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Module, attributeType As Type) As Attribute

Paramètres

element
Module

Module à inspecter.

attributeType
Type

Type d’attribut à rechercher.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

Plusieurs attributs demandés ont été trouvés.

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute(ParameterInfo, Type)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType);
public static Attribute? GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type) As Attribute

Paramètres

element
ParameterInfo

Paramètre à inspecter.

attributeType
Type

Type d’attribut à rechercher.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute(MemberInfo, Type, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié, et inspecte éventuellement les ancêtres de ce membre.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
public static Attribute? GetCustomAttribute (this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type, inherit As Boolean) As Attribute

Paramètres

element
MemberInfo

Membre à inspecter.

attributeType
Type

Type d’attribut à rechercher.

inherit
Boolean

true pour inspecter les ancêtres de element ; sinon, false.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute(ParameterInfo, Type, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié, et inspecte éventuellement les ancêtres de ce paramètre.

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
public static Attribute? GetCustomAttribute (this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type, inherit As Boolean) As Attribute

Paramètres

element
ParameterInfo

Paramètre à inspecter.

attributeType
Type

Type d’attribut à rechercher.

inherit
Boolean

true pour inspecter les ancêtres de element ; sinon, false.

Retours

Attribute

Attribut personnalisé correspondant à attributeType ou null si aucun attribut n'est trouvé.

Exceptions

element ou attributeType est null.

attributeType n'est pas dérivé de Attribute.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(ParameterInfo, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié, et inspecte éventuellement les ancêtres de ce paramètre.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element, bool inherit);
public static T GetCustomAttribute<T> (this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo, inherit As Boolean) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
ParameterInfo

Paramètre à inspecter.

inherit
Boolean

true pour inspecter les ancêtres de element ; sinon, false.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous attendez que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(MemberInfo, Boolean)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié, et inspecte éventuellement les ancêtres de ce membre.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element, bool inherit);
public static T GetCustomAttribute<T> (this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo, inherit As Boolean) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
MemberInfo

Membre à inspecter.

inherit
Boolean

true pour inspecter les ancêtres de element ; sinon, false.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(ParameterInfo)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un paramètre spécifié.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.ParameterInfo element) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.ParameterInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
ParameterInfo

Paramètre à inspecter.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(Module)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un module spécifié.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Module ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.Module element) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.Module element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Module -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Module) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
Module

Module à inspecter.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

Plusieurs attributs demandés ont été trouvés.

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(MemberInfo)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un membre spécifié.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.MemberInfo element) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.MemberInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
MemberInfo

Membre à inspecter.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

element n'est pas un constructeur, une méthode, une propriété, un événement, un type ou un champ.

Plusieurs attributs demandés ont été trouvés.

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

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à

GetCustomAttribute<T>(Assembly)

Récupère un attribut personnalisé d'un type spécifié qui est appliqué à un assembly spécifié.

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Assembly ^ element);
public static T GetCustomAttribute<T> (this System.Reflection.Assembly element) where T : Attribute;
public static T? GetCustomAttribute<T> (this System.Reflection.Assembly element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Assembly -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Assembly) As T

Paramètres de type

T

Type d’attribut à rechercher.

Paramètres

element
Assembly

Assembly à inspecter.

Retours

T

Attribut personnalisé correspondant à T ou null si aucun attribut n'est trouvé.

Exceptions

element a la valeur null.

Plusieurs attributs demandés ont été trouvés.

Remarques

Utilisez la GetCustomAttributes méthode d’extension si vous vous attendez à ce que plusieurs valeurs soient retournées ou AmbiguousMatchException levées.

S’applique à