Compartilhar via


CodeProperty.Setter Property

Sets or gets an object defining the code to set a property.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
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)

Property Value

Type: EnvDTE.CodeFunction
A CodeFunction object.

Remarks

Setter returns the code function, if any, that is the setter of this property.

Note

The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Examples

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 Security

See Also

Reference

CodeProperty Interface

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples