CustomAttributeExtensions.GetCustomAttribute Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Recupera un attributo personalizzato applicato a un elemento specificato.
Overload
| Nome | Descrizione |
|---|---|
| GetCustomAttribute(Assembly, Type) |
Recupera un attributo personalizzato di un tipo specificato applicato a un assembly specificato. |
| GetCustomAttribute(MemberInfo, Type) |
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato. |
| GetCustomAttribute(Module, Type) |
Recupera un attributo personalizzato di un tipo specificato applicato a un modulo specificato. |
| GetCustomAttribute(ParameterInfo, Type) |
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato. |
| GetCustomAttribute(MemberInfo, Type, Boolean) |
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro. |
| GetCustomAttribute(ParameterInfo, Type, Boolean) |
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato e, facoltativamente, esamina i predecessori di tale parametro. |
| GetCustomAttribute<T>(ParameterInfo, Boolean) |
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato e, facoltativamente, esamina i predecessori di tale parametro. |
| GetCustomAttribute<T>(MemberInfo, Boolean) |
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro. |
| GetCustomAttribute<T>(ParameterInfo) |
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato. |
| GetCustomAttribute<T>(Module) |
Recupera un attributo personalizzato di un tipo specificato applicato a un modulo specificato. |
| GetCustomAttribute<T>(MemberInfo) |
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato. |
| GetCustomAttribute<T>(Assembly) |
Recupera un attributo personalizzato di un tipo specificato applicato a un assembly specificato. |
GetCustomAttribute(Assembly, Type)
Recupera un attributo personalizzato di un tipo specificato applicato a un assembly specificato.
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);
static member GetCustomAttribute : System.Reflection.Assembly * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Assembly, attributeType As Type) As Attribute
Parametri
- element
- Assembly
Assembly da controllare.
- attributeType
- Type
Tipo di attributo da cercare.
Valori restituiti
Attributo personalizzato che corrisponde attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
È stato trovato più di uno degli attributi richiesti.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute(MemberInfo, Type)
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato.
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);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type) As Attribute
Parametri
- element
- MemberInfo
Membro da controllare.
- attributeType
- Type
Tipo di attributo da cercare.
Valori restituiti
Attributo personalizzato che corrisponde attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute(Module, Type)
Recupera un attributo personalizzato di un tipo specificato applicato a un modulo specificato.
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);
static member GetCustomAttribute : System.Reflection.Module * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Module, attributeType As Type) As Attribute
Parametri
- element
- Module
Modulo da esaminare.
- attributeType
- Type
Tipo di attributo da cercare.
Valori restituiti
Attributo personalizzato che corrisponde attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
È stato trovato più di uno degli attributi richiesti.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute(ParameterInfo, Type)
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato.
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);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type) As Attribute
Parametri
- element
- ParameterInfo
Parametro da esaminare.
- attributeType
- Type
Tipo di attributo da cercare.
Valori restituiti
Attributo personalizzato che corrisponde attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute(MemberInfo, Type, Boolean)
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.
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);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type, inherit As Boolean) As Attribute
Parametri
- element
- MemberInfo
Membro da controllare.
- attributeType
- Type
Tipo di attributo da cercare.
- inherit
- Boolean
true per controllare i predecessori di element; in caso contrario, false.
Valori restituiti
Attributo personalizzato che corrisponde attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute(ParameterInfo, Type, Boolean)
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato e, facoltativamente, esamina i predecessori di tale parametro.
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);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type, inherit As Boolean) As Attribute
Parametri
- element
- ParameterInfo
Parametro da esaminare.
- attributeType
- Type
Tipo di attributo da cercare.
- inherit
- Boolean
true per controllare i predecessori di element; in caso contrario, false.
Valori restituiti
Attributo personalizzato corrispondente attributeTypea o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element o attributeType è null.
attributeType non è derivato da Attribute.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(ParameterInfo, Boolean)
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato e, facoltativamente, esamina i predecessori di tale parametro.
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;
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
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- ParameterInfo
Parametro da esaminare.
- inherit
- Boolean
true per controllare i predecessori di element; in caso contrario, false.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(MemberInfo, Boolean)
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.
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;
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
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- MemberInfo
Membro da controllare.
- inherit
- Boolean
true per controllare i predecessori di element; in caso contrario, false.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(ParameterInfo)
Recupera un attributo personalizzato di un tipo specificato applicato a un parametro specificato.
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;
static member GetCustomAttribute : System.Reflection.ParameterInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo) As T
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- ParameterInfo
Parametro da esaminare.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(Module)
Recupera un attributo personalizzato di un tipo specificato applicato a un modulo specificato.
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;
static member GetCustomAttribute : System.Reflection.Module -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Module) As T
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- Module
Modulo da esaminare.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
È stato trovato più di uno degli attributi richiesti.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(MemberInfo)
Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato.
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;
static member GetCustomAttribute : System.Reflection.MemberInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo) As T
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- MemberInfo
Membro da controllare.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.
È stato trovato più di uno degli attributi richiesti.
Non è possibile caricare un tipo di attributo personalizzato.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.
Si applica a
GetCustomAttribute<T>(Assembly)
Recupera un attributo personalizzato di un tipo specificato applicato a un assembly specificato.
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;
static member GetCustomAttribute : System.Reflection.Assembly -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Assembly) As T
Parametri di tipo
- T
Tipo di attributo da cercare.
Parametri
- element
- Assembly
Assembly da controllare.
Valori restituiti
Attributo personalizzato che corrisponde Ta o null se non viene trovato alcun attributo di questo tipo.
Eccezioni
element è null.
È stato trovato più di uno degli attributi richiesti.
Commenti
Utilizzare il GetCustomAttributes metodo di estensione se si prevede che venga restituito più di un valore o AmbiguousMatchException che venga generata.