CodeProperty.Setter 属性

设置或获取一个对象,该对象定义代码以设置属性。

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

语法

声明
Property Setter As CodeFunction
CodeFunction Setter { get; set; }
property CodeFunction^ Setter {
    CodeFunction^ get ();
    void set (CodeFunction^ value);
}
abstract Setter : CodeFunction with get, set
function get Setter () : CodeFunction 
function set Setter (value : CodeFunction)

属性值

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

备注

Setter 返回作为此属性的 setter 的代码函数(如果有的话)。

备注

在进行某些类型的编辑之后,代码模型元素(如类、结构、函数、特性、委托等)的值可能是非确定性的,这意味着不能指望它们的值总是保持不变。有关更多信息,请参见 使用代码模型查找代码 (Visual Basic) 中的“代码模型元素的值可能会更改”一节。

示例

Sub SetterExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a property definition.
    Try
        ' Retrieve the CodeProperty at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim prop As CodeProperty = CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementProperty), CodeProperty)

        ' Display the source code for the property setter.
        Dim sttr As CodeFunction = prop.Setter
        Dim start As TextPoint = sttr.GetStartPoint()
        Dim finish As TextPoint = sttr.GetEndPoint()
        Dim src As String = start.CreateEditPoint().GetText(finish)

        MsgBox(prop.Name & "'s setter source code:" & vbCrLf & _
            vbCrLf & src)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub

.NET Framework 安全性

请参阅

参考

CodeProperty 接口

EnvDTE 命名空间

其他资源

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