CustomAttributeExtensions.GetCustomAttribute Метод
Определение
Получает настраиваемый атрибут, примененный к заданному элементу.Retrieves a custom attribute that is applied to a specified element.
Перегрузки
GetCustomAttribute(Assembly, Type) |
Извлекает пользовательский атрибут заданного типа, примененный к указанной сборке.Retrieves a custom attribute of a specified type that is applied to a specified assembly. |
GetCustomAttribute(MemberInfo, Type) |
Извлекает пользовательский атрибут заданного типа, примененный к указанному элементу.Retrieves a custom attribute of a specified type that is applied to a specified member. |
GetCustomAttribute(Module, Type) |
Извлекает пользовательский атрибут заданного типа, примененный к указанному модулю.Retrieves a custom attribute of a specified type that is applied to a specified module. |
GetCustomAttribute(ParameterInfo, Type) |
Извлекает пользовательский атрибут заданного типа, примененный к указанной параметру.Retrieves a custom attribute of a specified type that is applied to a specified parameter. |
GetCustomAttribute(MemberInfo, Type, Boolean) |
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному элементу и, при необходимости, проверяет предков этого элемента.Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. |
GetCustomAttribute(ParameterInfo, Type, Boolean) |
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному параметру и, при необходимости, проверяет предков этого параметра.Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter. |
GetCustomAttribute<T>(ParameterInfo, Boolean) |
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному параметру и, при необходимости, проверяет предков этого параметра.Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter. |
GetCustomAttribute<T>(MemberInfo, Boolean) |
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному элементу и, при необходимости, проверяет предков этого элемента.Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. |
GetCustomAttribute<T>(ParameterInfo) |
Извлекает пользовательский атрибут заданного типа, примененный к указанной параметру.Retrieves a custom attribute of a specified type that is applied to a specified parameter. |
GetCustomAttribute<T>(Module) |
Извлекает пользовательский атрибут заданного типа, примененный к указанному модулю.Retrieves a custom attribute of a specified type that is applied to a specified module. |
GetCustomAttribute<T>(MemberInfo) |
Извлекает пользовательский атрибут заданного типа, примененный к указанному элементу.Retrieves a custom attribute of a specified type that is applied to a specified member. |
GetCustomAttribute<T>(Assembly) |
Извлекает пользовательский атрибут заданного типа, примененный к указанной сборке.Retrieves a custom attribute of a specified type that is applied to a specified assembly. |
GetCustomAttribute(Assembly, Type)
Извлекает пользовательский атрибут заданного типа, примененный к указанной сборке.Retrieves a custom attribute of a specified type that is applied to a specified assembly.
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
Параметры
- element
- Assembly
Сборка для проверки.The assembly to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute that matches attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute(MemberInfo, Type)
Извлекает пользовательский атрибут заданного типа, примененный к указанному элементу.Retrieves a custom attribute of a specified type that is applied to a specified member.
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
Параметры
- element
- MemberInfo
Проверяемый член.The member to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute that matches attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute(Module, Type)
Извлекает пользовательский атрибут заданного типа, примененный к указанному модулю.Retrieves a custom attribute of a specified type that is applied to a specified module.
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
Параметры
- element
- Module
Проверяемый модуль.The module to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute that matches attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute(ParameterInfo, Type)
Извлекает пользовательский атрибут заданного типа, примененный к указанной параметру.Retrieves a custom attribute of a specified type that is applied to a specified parameter.
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
Параметры
- element
- ParameterInfo
Проверяемый параметр.The parameter to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute that matches attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute(MemberInfo, Type, Boolean)
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному элементу и, при необходимости, проверяет предков этого элемента.Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.
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
Параметры
- element
- MemberInfo
Проверяемый член.The member to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
- inherit
- Boolean
Значение true
для проверки предков element
; в противном случае — значение false
.true
to inspect the ancestors of element
; otherwise, false
.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute that matches attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute(ParameterInfo, Type, Boolean)
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному параметру и, при необходимости, проверяет предков этого параметра.Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.
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
Параметры
- element
- ParameterInfo
Проверяемый параметр.The parameter to inspect.
- attributeType
- Type
Тип атрибута для поиска.The type of attribute to search for.
- inherit
- Boolean
Значение true
для проверки предков element
; в противном случае — значение false
.true
to inspect the ancestors of element
; otherwise, false
.
Возвращаемое значение
Настраиваемый атрибут, соответствующий attributeType
, или значение null
, если такой атрибут не найден.A custom attribute matching attributeType
, or null
if no such attribute is found.
Исключения
Параметр element
или attributeType
имеет значение null
.element
or attributeType
is null
.
Тип attributeType
не является производным объекта Attribute.attributeType
is not derived from Attribute.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(ParameterInfo, Boolean)
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному параметру и, при необходимости, проверяет предков этого параметра.Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- ParameterInfo
Проверяемый параметр.The parameter to inspect.
- inherit
- Boolean
Значение true
для проверки предков element
; в противном случае — значение false
.true
to inspect the ancestors of element
; otherwise, false
.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(MemberInfo, Boolean)
Извлекает настраиваемый атрибут указанного типа, который применяется к указанному элементу и, при необходимости, проверяет предков этого элемента.Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- MemberInfo
Проверяемый член.The member to inspect.
- inherit
- Boolean
Значение true
для проверки предков element
; в противном случае — значение false
.true
to inspect the ancestors of element
; otherwise, false
.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(ParameterInfo)
Извлекает пользовательский атрибут заданного типа, примененный к указанной параметру.Retrieves a custom attribute of a specified type that is applied to a specified parameter.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- ParameterInfo
Проверяемый параметр.The parameter to inspect.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(Module)
Извлекает пользовательский атрибут заданного типа, примененный к указанному модулю.Retrieves a custom attribute of a specified type that is applied to a specified module.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- Module
Проверяемый модуль.The module to inspect.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(MemberInfo)
Извлекает пользовательский атрибут заданного типа, примененный к указанному элементу.Retrieves a custom attribute of a specified type that is applied to a specified member.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- MemberInfo
Проверяемый член.The member to inspect.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
element
не представляет конструктор, метод, свойство, событие, тип или поле.element
is not a constructor, method, property, event, type, or field.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Не удалось загрузить тип настраиваемого атрибута.A custom attribute type cannot be loaded.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.
Применяется к
GetCustomAttribute<T>(Assembly)
Извлекает пользовательский атрибут заданного типа, примененный к указанной сборке.Retrieves a custom attribute of a specified type that is applied to a specified assembly.
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
Параметры типа
- T
Тип атрибута для поиска.The type of attribute to search for.
Параметры
- element
- Assembly
Сборка для проверки.The assembly to inspect.
Возвращаемое значение
- T
Настраиваемый атрибут, соответствующий T
, или значение null
, если такой атрибут не найден.A custom attribute that matches T
, or null
if no such attribute is found.
Исключения
element
имеет значение null
.element
is null
.
Найдено несколько запрошенных атрибутов.More than one of the requested attributes was found.
Комментарии
Используйте GetCustomAttributes метод расширения, если предполагается, что возвращается более одного значения или AmbiguousMatchException будет выдано исключение.Use the GetCustomAttributes extension method if you expect more than one value to be returned, or AmbiguousMatchException will be thrown.