CustomAttributeExtensions.GetCustomAttribute Metodo

Definizione

Recupera un attributo personalizzato applicato a un elemento specificato.

Overload

GetCustomAttribute(Assembly, Type)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un assembly specificato.

GetCustomAttribute(MemberInfo, Type)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un membro specificato.

GetCustomAttribute(Module, Type)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un modulo specificato.

GetCustomAttribute(ParameterInfo, Type)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato.

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato e verifica facoltativamente i predecessori di tale parametro.

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato e verifica facoltativamente i predecessori di tale parametro.

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttribute<T>(ParameterInfo)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato.

GetCustomAttribute<T>(Module)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un modulo specificato.

GetCustomAttribute<T>(MemberInfo)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un membro specificato.

GetCustomAttribute<T>(Assembly)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un assembly specificato.

GetCustomAttribute(Assembly, Type)

Recupera una attributo personalizzato di un tipo specificato che viene 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);
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

L'assembly da ispezionare.

attributeType
Type

Tipo di attributo da cercare.

Restituisce

Attribute

Attributo personalizzato corrispondente a attributeType o null se questo attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

È stato trovato più di un attributo richiesto.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute(MemberInfo, Type)

Recupera una attributo personalizzato di un tipo specificato che viene 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);
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

Il membro da ispezionare.

attributeType
Type

Tipo di attributo da cercare.

Restituisce

Attribute

Attributo personalizzato corrispondente a attributeType o null se questo attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute(Module, Type)

Recupera una attributo personalizzato di un tipo specificato che viene 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);
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 controllare.

attributeType
Type

Tipo di attributo da cercare.

Restituisce

Attribute

Attributo personalizzato corrispondente a attributeType o null se questo attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

È stato trovato più di un attributo richiesto.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute(ParameterInfo, Type)

Recupera una attributo personalizzato di un tipo specificato che viene 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);
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

Il parametro da ispezionare.

attributeType
Type

Tipo di attributo da cercare.

Restituisce

Attribute

Attributo personalizzato corrispondente a attributeType o null se questo attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente 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);
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

Il membro da ispezionare.

attributeType
Type

Tipo di attributo da cercare.

inherit
Boolean

true per ispezionare i predecessori di element; in caso contrario, false.

Restituisce

Attribute

Attributo personalizzato corrispondente a attributeType o null se questo attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato e verifica facoltativamente 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);
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

Il parametro da ispezionare.

attributeType
Type

Tipo di attributo da cercare.

inherit
Boolean

true per ispezionare i predecessori di element; in caso contrario, false.

Restituisce

Attribute

Attributo personalizzato che corrisponde a attributeType o a null se tale attributo non viene trovato.

Eccezioni

element o attributeType è null.

attributeType non deriva da Attribute.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un parametro specificato e verifica facoltativamente 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;
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

Il parametro da ispezionare.

inherit
Boolean

true per ispezionare i predecessori di element; in caso contrario, false.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente 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;
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

Il membro da ispezionare.

inherit
Boolean

true per ispezionare i predecessori di element; in caso contrario, false.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(ParameterInfo)

Recupera una attributo personalizzato di un tipo specificato che viene 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;
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

Il parametro da ispezionare.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(Module)

Recupera una attributo personalizzato di un tipo specificato che viene 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;
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 controllare.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

È stato trovato più di un attributo richiesto.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(MemberInfo)

Recupera una attributo personalizzato di un tipo specificato che viene 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;
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

Il membro da ispezionare.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

element non è un costruttore, un metodo, una proprietà, un evento, un tipo o un campo.

È stato trovato più di un attributo richiesto.

Non è possibile caricare un tipo di attributo personalizzato.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a

GetCustomAttribute<T>(Assembly)

Recupera una attributo personalizzato di un tipo specificato che viene 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;
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

L'assembly da ispezionare.

Restituisce

T

Attributo personalizzato corrispondente a T o null se questo attributo non viene trovato.

Eccezioni

element è null.

È stato trovato più di un attributo richiesto.

Commenti

Utilizzare il metodo di estensione GetCustomAttributes se si prevede più di un valore da restituire oppure verrà generata un'eccezione AmbiguousMatchException.

Si applica a