FileCodeModel.AddAttribute 方法

创建新的特性代码构造,并将代码插入正确的位置。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Function AddAttribute ( _
    Name As String, _
    Value As String, _
    Position As Object _
) As CodeAttribute
CodeAttribute AddAttribute(
    string Name,
    string Value,
    Object Position
)
CodeAttribute^ AddAttribute(
    String^ Name, 
    String^ Value, 
    Object^ Position
)
abstract AddAttribute : 
        Name:string * 
        Value:string * 
        Position:Object -> CodeAttribute 
function AddAttribute(
    Name : String, 
    Value : String, 
    Position : Object
) : CodeAttribute

参数

  • Value
    类型:System.String
    必选。特性的值,该值可以是参数化属性的逗号分隔参数列表。
  • Position
    类型:System.Object
    可选。默认值 = 0。将在其后添加新元素的代码元素。如果该值为 CodeElement,则紧跟在其后添加新元素。
    如果该值为 Long 数据类型,则 AddAttribute 指示在哪个元素的后面添加新元素。
    因为集合从 1 开始计数,所以传递 0 指示应将新元素放置在集合的开始处。值为 -1 表示应将元素放在结尾处。

返回值

类型:EnvDTE.CodeAttribute
一个 CodeAttribute 对象。

备注

如果该特性已存在,则 AddAttribute 将添加另一个特性。 这对于代码模型后面的特性或语言可能是不正确的。

.NET Framework 安全性

请参见

参考

FileCodeModel 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例