CustomAttributeExtensions.GetCustomAttribute Método

Definición

Recupera un atributo personalizado aplicado a un elemento especificado.

Sobrecargas

GetCustomAttribute(Assembly, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un ensamblado concreto.

GetCustomAttribute(MemberInfo, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto.

GetCustomAttribute(Module, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un módulo concreto.

GetCustomAttribute(ParameterInfo, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto.

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto y, opcionalmente, inspecciona los antecesores de dicho miembro.

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto y, opcionalmente, inspecciona los antecesores de dicho parámetro.

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto y, opcionalmente, inspecciona los antecesores de dicho parámetro.

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto y, opcionalmente, inspecciona los antecesores de dicho miembro.

GetCustomAttribute<T>(ParameterInfo)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto.

GetCustomAttribute<T>(Module)

Recupera un atributo personalizado de un tipo especificado que se aplica a un módulo concreto.

GetCustomAttribute<T>(MemberInfo)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto.

GetCustomAttribute<T>(Assembly)

Recupera un atributo personalizado de un tipo especificado que se aplica a un ensamblado concreto.

GetCustomAttribute(Assembly, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un ensamblado concreto.

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

Ensamblado que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

Se ha encontrado más de un atributo de los atributos solicitados.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute(MemberInfo, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto.

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

Miembro que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute(Module, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un módulo concreto.

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

Módulo que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

Se ha encontrado más de un atributo de los atributos solicitados.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute(ParameterInfo, Type)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto.

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

Parámetro que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto y, opcionalmente, inspecciona los antecesores de dicho miembro.

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

Miembro que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

inherit
Boolean

Es true para inspeccionar los antecesores de element; de lo contrario, es false.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute(ParameterInfo, Type, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto y, opcionalmente, inspecciona los antecesores de dicho 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

Parámetro que se va a inspeccionar.

attributeType
Type

El tipo de atributo que se va a buscar.

inherit
Boolean

Es true para inspeccionar los antecesores de element; de lo contrario, es false.

Devoluciones

Attribute

Atributo personalizado que coincide con attributeType, o null si no se encuentra ningún atributo.

Excepciones

element o attributeType es null.

attributeType no se deriva de Attribute.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(ParameterInfo, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto y, opcionalmente, inspecciona los antecesores de dicho 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

El tipo de atributo que se va a buscar.

Parámetros

element
ParameterInfo

Parámetro que se va a inspeccionar.

inherit
Boolean

Es true para inspeccionar los antecesores de element; de lo contrario, es false.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto y, opcionalmente, inspecciona los antecesores de dicho miembro.

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

El tipo de atributo que se va a buscar.

Parámetros

element
MemberInfo

Miembro que se va a inspeccionar.

inherit
Boolean

Es true para inspeccionar los antecesores de element; de lo contrario, es false.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(ParameterInfo)

Recupera un atributo personalizado de un tipo especificado que se aplica a un parámetro concreto.

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

El tipo de atributo que se va a buscar.

Parámetros

element
ParameterInfo

Parámetro que se va a inspeccionar.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(Module)

Recupera un atributo personalizado de un tipo especificado que se aplica a un módulo concreto.

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

El tipo de atributo que se va a buscar.

Parámetros

element
Module

Módulo que se va a inspeccionar.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

Se ha encontrado más de un atributo de los atributos solicitados.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(MemberInfo)

Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro concreto.

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

El tipo de atributo que se va a buscar.

Parámetros

element
MemberInfo

Miembro que se va a inspeccionar.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

element no es un constructor, método, propiedad, evento, tipo o campo.

Se ha encontrado más de un atributo de los atributos solicitados.

No se puede cargar un tipo de atributo personalizado.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a

GetCustomAttribute<T>(Assembly)

Recupera un atributo personalizado de un tipo especificado que se aplica a un ensamblado concreto.

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

El tipo de atributo que se va a buscar.

Parámetros

element
Assembly

Ensamblado que se va a inspeccionar.

Devoluciones

T

Atributo personalizado que coincide con T, o null si no se encuentra ningún atributo.

Excepciones

element es null.

Se ha encontrado más de un atributo de los atributos solicitados.

Comentarios

Use el GetCustomAttributes método de extensión si espera que se devuelva más de un valor o AmbiguousMatchException se producirá.

Se aplica a