Freigeben über


CodeFunction2.FunctionKind-Eigenschaft

Ruft eine Enumeration ab, die beschreibt, wie eine Funktion verwendet wird.

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

Syntax

'Declaration
ReadOnly Property FunctionKind As vsCMFunction
vsCMFunction FunctionKind { get; }
property vsCMFunction FunctionKind {
    vsCMFunction get ();
}
abstract FunctionKind : vsCMFunction with get
function get FunctionKind () : vsCMFunction

Eigenschaftswert

Typ: vsCMFunction
Ein vsCMFunction-Wert.

Hinweise

FunctionKind Gibt den Typ der Funktion, wie z. B. Property Get, Property Let, Sub oder eine Funktion.

Die vsCMFunction Werte werden sollen bitweisen Operator OR zusammengefügt. Visual C++ vereint mehrere dieser Werte, um eine Funktion genau zu beschreiben. Beispiel:

virtual int MyProc() const = 0;

MyProc führt zu einem Wert von (vsCMFunctionFunction | vsCMFunctionVirtual | vsCMFunctionConstant | vsCMFunctionPure | vsCMFunctionTopLevel).

Ein weiteres Beispiel:

inline void AnotherOne()

führt zu einem Wert von (vsCMFunctionSub | vsCMFunctionInline, vsCMFunctionTopLevel).

Hinweis

Die Werte von Codemodellelementen wie z. B. Klassen, Strukturen, Funktionen, Attributen Delegaten usw. sind nach bestimmten Änderungen unter Umständen nicht deterministisch, d. h. deren Werte bleiben nicht zuverlässig immer gleich.Weitere Informationen finden Sie im Abschnitt "Codemodellelemente können sich ändern" in Ermitteln von Code über das Codemodell (Visual Basic).

Beispiele

Sub FunctionKindExample(ByVal dte As DTE2)

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

        MsgBox(fun.Name & "'s kind is " & fun.FunctionKind.ToString())
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void FunctionKindExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a function.
    try
    {
        // Retrieve the CodeFunction at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeFunction fun = 
            (CodeFunction)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementFunction);

        MessageBox.Show(fun.Name + "'s kind is " + 
            fun.FunctionKind.ToString());
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

CodeFunction2 Schnittstelle

EnvDTE80-Namespace

Weitere Ressourcen

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell

Ermitteln von Code über das Codemodell (Visual Basic)

Ermitteln von Code über das Codemodell (Visual C#)