CodeFunction.MustImplement Eigenschaft

Definition

Legt fest oder Ruft ab, ob das Element als abstrakt deklariert ist, und erfordert daher eine-Implementierung.

public:
 property bool MustImplement { bool get(); void set(bool value); };
public:
 property bool MustImplement { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(41)]
public bool MustImplement { [System.Runtime.InteropServices.DispId(41)] get; [System.Runtime.InteropServices.DispId(41)] set; }
[<System.Runtime.InteropServices.DispId(41)>]
[<get: System.Runtime.InteropServices.DispId(41)>]
[<set: System.Runtime.InteropServices.DispId(41)>]
member this.MustImplement : bool with get, set
Public Property MustImplement As Boolean

Eigenschaftswert

Boolean

Ein boolescher Wert true , der angibt, ob die Methode als abstrakt deklariert ist und daher eine Implementierung erfordert; false andernfalls.

Attribute

Beispiele

 Sub MustImplementExample(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)  

        Dim mustImpl As String  
        Dim elem As CodeElement  
        For Each elem In cls.Members  
            If (elem.Kind = vsCMElement.vsCMElementFunction) Then  
                Dim fun As CodeFunction = CType(elem, CodeFunction)  
                If fun.MustImplement Then  
                    mustImpl &= fun.Prototype( _  
                        vsCMPrototype.vsCMPrototypeParamNames Or _  
                        vsCMPrototype.vsCMPrototypeParamTypes Or _  
                        vsCMPrototype.vsCMPrototypeType) & vbCrLf  
                End If  
            End If  
        Next  

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

End Sub  
 public void MustImplementExample(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);  
        string mustImpl = "";  

        foreach (CodeElement elem in cls.Members)  
        {  
            if (elem.Kind == vsCMElement.vsCMElementFunction)  
            {  
                CodeFunction fun = (CodeFunction)elem;  

                if (fun.MustImplement)  
                    mustImpl += fun.get_Prototype(  
                        (int)(vsCMPrototype.vsCMPrototypeParamNames |   
                        vsCMPrototype.vsCMPrototypeParamTypes |   
                        vsCMPrototype.vsCMPrototypeType)) + "\n";  
            }  
        }  

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

Hinweise

MustImplement Gibt zurück oder legt fest, ob die Methode implementiert ist oder eine Implementierung in Unterklassen erfordert. Beachten Sie, dass dies False für einige Sprachen immer sein kann, und die Einstellung MustImplement kann je nach Sprache fehlschlagen.

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 Code Modell Element-Werte können sich in ermitteln von Code mithilfe des Code Modells (Visual Basic)ändern.

Gilt für