MemberInfo.GetCustomAttributesData 方法

定义

返回 CustomAttributeData 对象列表,这些对象表示已应用到目标成员的特性相关数据。

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)

返回

IList<CustomAttributeData>

CustomAttributeData 对象的泛型列表,表示有关已应用于目标成员的特性的数据。

注解

如果自定义特性本身是在加载到仅反射上下文中的代码中定义的,则使用此方法检查仅反射上下文中代码的自定义属性。 在这种情况下不能使用 和 等方法 Attribute.GetCustomAttributes MemberInfo.GetCustomAttributes ,因为它们会创建属性的实例。 无法执行仅反射上下文中的代码。 有关详细信息和示例代码,请参阅 CustomAttributeData 类。

此方法获取类型、嵌套类型和类型成员的自定义属性数据,因为 类和 命名空间中表示类型成员的类均 Type System.Reflection 派生自 MemberInfo

适用于