CustomAttributeExtensions.GetCustomAttribute Método

Definição

Recupera um atributo personalizado que é aplicados a um elemento especificado.

Sobrecargas

GetCustomAttribute(Assembly, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um assembly especificado.

GetCustomAttribute(MemberInfo, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado.

GetCustomAttribute(Module, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um módulo especificado.

GetCustomAttribute(ParameterInfo, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado.

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado e opcionalmente inspeciona os ancestrais desse membro.

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado e opcionalmente inspeciona os ancestrais desse parâmetro.

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado e opcionalmente inspeciona os ancestrais desse parâmetro.

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado e opcionalmente inspeciona os ancestrais desse membro.

GetCustomAttribute<T>(ParameterInfo)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado.

GetCustomAttribute<T>(Module)

Recupera um atributo personalizado de um tipo especificado aplicado a um módulo especificado.

GetCustomAttribute<T>(MemberInfo)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado.

GetCustomAttribute<T>(Assembly)

Recupera um atributo personalizado de um tipo especificado aplicado a um assembly especificado.

GetCustomAttribute(Assembly, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um assembly especificado.

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

Parâmetros

element
Assembly

O assembly a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo é encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

Mais de um dos atributos solicitados foi encontrado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute(MemberInfo, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado.

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

Parâmetros

element
MemberInfo

O membro a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo é encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute(Module, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um módulo especificado.

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

Parâmetros

element
Module

O módulo a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo é encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

Mais de um dos atributos solicitados foi encontrado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute(ParameterInfo, Type)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado.

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

Parâmetros

element
ParameterInfo

O parâmetro a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo é encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado e opcionalmente inspeciona os ancestrais desse 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

Parâmetros

element
MemberInfo

O membro a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

inherit
Boolean

true para inspecionar os ancestrais de element; caso contrário, false.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo é encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado e opcionalmente inspeciona os ancestrais desse parâmetro.

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

Parâmetros

element
ParameterInfo

O parâmetro a ser inspecionado.

attributeType
Type

O tipo de atributo a ser pesquisado.

inherit
Boolean

true para inspecionar os ancestrais de element; caso contrário, false.

Retornos

Attribute

Um atributo personalizado que corresponde a attributeType ou null se nenhum atributo for encontrado.

Exceções

element ou attributeType é null.

attributeType não é derivado de Attribute.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado e opcionalmente inspeciona os ancestrais desse parâmetro.

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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
ParameterInfo

O parâmetro a ser inspecionado.

inherit
Boolean

true para inspecionar os ancestrais de element; caso contrário, false.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado e opcionalmente inspeciona os ancestrais desse 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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
MemberInfo

O membro a ser inspecionado.

inherit
Boolean

true para inspecionar os ancestrais de element; caso contrário, false.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(ParameterInfo)

Recupera um atributo personalizado de um tipo especificado aplicado a um parâmetro especificado.

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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
ParameterInfo

O parâmetro a ser inspecionado.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(Module)

Recupera um atributo personalizado de um tipo especificado aplicado a um módulo especificado.

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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
Module

O módulo a ser inspecionado.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

Mais de um dos atributos solicitados foi encontrado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(MemberInfo)

Recupera um atributo personalizado de um tipo especificado aplicado a um membro especificado.

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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
MemberInfo

O membro a ser inspecionado.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

O element não é um construtor, método, propriedade, evento, tipo nem campo.

Mais de um dos atributos solicitados foi encontrado.

Um tipo de atributo personalizado não pode ser carregado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a

GetCustomAttribute<T>(Assembly)

Recupera um atributo personalizado de um tipo especificado aplicado a um assembly especificado.

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

Parâmetros de tipo

T

O tipo de atributo a ser pesquisado.

Parâmetros

element
Assembly

O assembly a ser inspecionado.

Retornos

T

Um atributo personalizado que corresponde a T ou null se nenhum atributo é encontrado.

Exceções

element é null.

Mais de um dos atributos solicitados foi encontrado.

Comentários

Use o GetCustomAttributes método de extensão se você espera que mais de um valor seja retornado ou AmbiguousMatchException será lançado.

Aplica-se a