MemberInfo.GetCustomAttributesData MemberInfo.GetCustomAttributesData MemberInfo.GetCustomAttributesData MemberInfo.GetCustomAttributesData Method

定义

返回 CustomAttributeData 对象列表,这些对象表示已应用到目标成员的特性相关数据。Returns a list of CustomAttributeData objects representing data about the attributes that have been applied to the target member.

public:
 virtual System::Collections::Generic::IList<System::Reflection::CustomAttributeData ^> ^ GetCustomAttributesData();
public virtual System.Collections.Generic.IList<System.Reflection.CustomAttributeData> GetCustomAttributesData ();
abstract member GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
override this.GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
Public Overridable Function GetCustomAttributesData () As IList(Of CustomAttributeData)

返回

CustomAttributeData 对象的泛型列表,表示有关已应用于目标成员的特性的数据。A generic list of CustomAttributeData objects representing data about the attributes that have been applied to the target member.

注解

此方法用于检查代码中的仅限反射的上下文,在其中加载到仅反射上下文的代码中定义的自定义特性本身的情况下的自定义特性。Use this method to examine the custom attributes of code in the reflection-only context, in cases where the custom attributes themselves are defined in code that is loaded into the reflection-only context. 等方法Attribute.GetCustomAttributesMemberInfo.GetCustomAttributes能在这种情况下,因为它们创建特性的实例。Methods like Attribute.GetCustomAttributes and MemberInfo.GetCustomAttributes cannot be used in such cases, because they create instances of the attributes. 不能执行仅限反射上下文中的代码。Code in the reflection-only context cannot be executed. 有关详细信息和有关示例代码,请参阅CustomAttributeData类。For more information and for example code, see the CustomAttributeData class.

此方法获取自定义属性数据类型、 嵌套的类型和类型成员,因为Type类和中的类System.Reflection表示所有派生的类型成员的命名空间MemberInfoThis method gets custom attribute data for types, nested types, and type members, because the Type class and the classes in the System.Reflection namespace that represent type members all derive from MemberInfo.

适用于