ICustomAttributeProvider.GetCustomAttributes 方法

定义

返回此成员上定义的自定义属性。

重载

GetCustomAttributes(Boolean)

返回在该成员上定义的所有自定义特性的数组(已命名的特性除外),如果没有自定义特性,则返回空数组。

GetCustomAttributes(Type, Boolean)

返回在该成员上定义、由类型标识的自定义属性数组,如果没有该类型的自定义属性,则返回空数组。

GetCustomAttributes(Boolean)

返回在该成员上定义的所有自定义特性的数组(已命名的特性除外),如果没有自定义特性,则返回空数组。

public:
 cli::array <System::Object ^> ^ GetCustomAttributes(bool inherit);
public object[] GetCustomAttributes (bool inherit);
abstract member GetCustomAttributes : bool -> obj[]
Public Function GetCustomAttributes (inherit As Boolean) As Object()

参数

inherit
Boolean

true 时,查找继承的自定义特性的层次结构链。

返回

Object[]

表示自定义特性的对象数组或空数组。

例外

无法加载自定义特性类型。

此成员上定义了多个 attributeType 类型的特性。

注解

调用ICustomAttributeProvider.GetCustomAttributesEventInfo当参数GetCustomAttributes``true不执行类型层次结构时inheritPropertyInfo 用于 System.Attribute 继承自定义属性。

此方法仅返回直接在非继承成员上定义的自定义属性。

适用于

GetCustomAttributes(Type, Boolean)

返回在该成员上定义、由类型标识的自定义属性数组,如果没有该类型的自定义属性,则返回空数组。

public:
 cli::array <System::Object ^> ^ GetCustomAttributes(Type ^ attributeType, bool inherit);
public object[] GetCustomAttributes (Type attributeType, bool inherit);
abstract member GetCustomAttributes : Type * bool -> obj[]
Public Function GetCustomAttributes (attributeType As Type, inherit As Boolean) As Object()

参数

attributeType
Type

自定义属性的类型。

inherit
Boolean

true 时,查找继承的自定义特性的层次结构链。

返回

Object[]

表示自定义特性的对象数组或空数组。

例外

无法加载自定义特性类型。

attributeTypenull

注解

如果 attributeType 为基类或接口,此方法将返回该类型的任何实现。

此方法仅返回直接在非继承成员上定义的自定义属性。

调用ICustomAttributeProvider.GetCustomAttributesEventInfo当参数GetCustomAttributes``true不执行类型层次结构时inheritPropertyInfo 用于 System.Attribute 继承自定义属性。

适用于