Share via


CodeProperty.Setter 屬性

設定或取得用來定義程式碼以設定屬性的物件。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Property Setter As CodeFunction
    Get
    Set
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 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例