Właściwość CodeFunction.CanOverride —

Ustawia lub pobiera, niezależnie od tego, czy funkcja może zostać zastąpiona.

Przestrzeń nazw:  EnvDTE
Zestaw:  EnvDTE (w EnvDTE.dll)

Składnia

'Deklaracja
Property CanOverride As Boolean
bool CanOverride { get; set; }
property bool CanOverride {
    bool get ();
    void set (bool value);
}
abstract CanOverride : bool with get, set
function get CanOverride () : boolean 
function set CanOverride (value : boolean)

Wartość właściwości

Typ: Boolean
Wartość logiczna wskazująca true , jeśli funkcja może być zastąpione; falseJeśli inaczej.

Uwagi

Dla języka Visual Basic, funkcja został uznany za z MustOverride lub Overrideable.

Visual C# i Visual C++, funkcja została zadeklarowana z virtual słowa kluczowego.

Dla języka JScript, funkcja została zadeklarowana z static lub final słowa kluczowe; oznacza to, że metody może być niejawnie zastąpiona.

[!UWAGA]

Po dokonaniu niektórych rodzajów modyfikacji, co oznacza, że ich wartości nie może polegać na zawsze pozostawać taki sam może być nie deterministyczny wartości elementów modelu kodu, takich jak klasy, strukturach, funkcje, atrybuty, delegatów i tak dalej.Aby uzyskać więcej informacji, zobacz sekcję wartości elementu modelu kod można zmienić w Odnajdowanie kodu za pomocą modelu kodu (Visual Basic).

Przykłady

 Sub CanOverrideExample(ByVal dte As DTE2)

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

        ' Find the class's overridable methods.
        Dim ovrrides As String
        Dim elem As CodeElement
        For Each elem In cls.Members
            If elem.Kind = vsCMElement.vsCMElementFunction AndAlso _
                CType(elem, CodeFunction).CanOverride Then
                ovrrides &= elem.Name & vbCrLf
            End If
        Next

        MsgBox(cls.Name & " has the following overridable methods:" & _
            vbCrLf & vbCrLf & ovrrides)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
 public void CanOverrideExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a class definition.
    try
    {
        // Retrieve the CodeClass at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeClass cls = 
            (CodeClass)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementClass);

        // Find the class's overridable methods.
        string overrides = "";
        
        foreach (CodeElement elem in cls.Members)
        {
            if ((elem.Kind == vsCMElement.vsCMElementFunction) && 
                ((CodeFunction)elem).CanOverride)
                overrides += elem.Name + "\r\n";
        }

        MessageBox.Show(cls.Name + 
            " has the following overridable methods:" + "\r\n\r\n" + 
            overrides);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

CodeFunction Interfejs

Przestrzeń nazw EnvDTE

Inne zasoby

Porady: kompilowanie i uruchamianie kodu modelu obiektów automatyzacji — przykłady

Odnajdowanie kodu za pomocą modelu kodu (Visual Basic)

Odnajdowanie kodu za pomocą modelu kodu (Visual C#)