AttributeTable.ContainsAttributes 方法

返回一个值,该值指示此表是否包含指定类型的任何元数据。

命名空间:  Microsoft.Windows.Design.Metadata
程序集:  Microsoft.Windows.Design.Extensibility(在 Microsoft.Windows.Design.Extensibility.dll 中)

语法

声明
Public Function ContainsAttributes ( _
    type As Type _
) As Boolean
public bool ContainsAttributes(
    Type type
)
public:
bool ContainsAttributes(
    Type^ type
)
member ContainsAttributes : 
        type:Type -> bool 
public function ContainsAttributes(
    type : Type
) : boolean

参数

  • type
    类型:System.Type
    要对其检查元数据特性的类型。

返回值

类型:System.Boolean
如果表中包含指定类型的特性,则为 true;否则为 false。

异常

异常 条件
ArgumentNullException

type 为 nullnull 引用(在 Visual Basic 中为 Nothing)。

备注

元数据可能是类级别元数据或者与 DependencyPropertyMemberDescriptor 相关的元数据。 使用此方法来标识加载的类型,这些类型需要在添加新特性表时引发的 Refreshed 事件,并需要快速确定应该在特性查询期间进一步查询的表。

示例

下面的代码示例演示如何使用 ContainsAttributes 方法来确定类型是否具有自定义特性。 此代码示例摘自为 AttributeTable 类提供的一个更大的示例。

Dim hasCustomAttributes As Boolean = attributes.ContainsAttributes(GetType(Button))
bool hasCustomAttributes = attributes.ContainsAttributes(typeof(Button));

.NET Framework 安全性

请参见

参考

AttributeTable 类

Microsoft.Windows.Design.Metadata 命名空间

AttributeTableBuilder