AttributeTableBuilder.AddCustomAttributes 方法 (Type, array<Attribute[])
[本文档仅供预览,在以后的发行版中可能会发生更改。包含的空白主题用作占位符。]
将提供的特性的内容添加到表生成器。
命名空间: Microsoft.Windows.Design.Metadata
程序集: Microsoft.Windows.Design.Extensibility(在 Microsoft.Windows.Design.Extensibility.dll 中)
语法
声明
Public Sub AddCustomAttributes ( _
type As Type, _
ParamArray attributes As Attribute() _
)
public void AddCustomAttributes(
Type type,
params Attribute[] attributes
)
public:
void AddCustomAttributes(
Type^ type,
... array<Attribute^>^ attributes
)
member AddCustomAttributes :
type:Type *
attributes:Attribute[] -> unit
public function AddCustomAttributes(
type : Type,
... attributes : Attribute[]
)
参数
- type
类型:System.Type
要为其添加类级别特性的类型。
- attributes
类型:array<System.Attribute[]
要添加到 type 的新特性。
异常
异常 | 条件 |
---|---|
ArgumentNullException | type 或 attributes 为 nulla null reference (Nothing in Visual Basic)。 |
备注
使用最后的更新生效策略来解决冲突。 创建大特性表时,请使用 AddCallback 方法将创建特性的工作推迟至它们需要时。
示例
下面的代码示例演示如何将特性添加到类型中。 此代码示例摘自为 AttributeTableBuilder 类提供的一个更大的示例。
builder.AddCustomAttributes( _
GetType(Button), _
New DefaultPropertyAttribute("Content"))
builder.AddCustomAttributes(
typeof(Button),
new DefaultPropertyAttribute("Content"));
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。