Partilhar via


CodeClass.ImplementedInterfaces Property

Definition

Gets a collection of interfaces implemented by a CodeClass object.

public:
 property EnvDTE::CodeElements ^ ImplementedInterfaces { EnvDTE::CodeElements ^ get(); };
[System.Runtime.InteropServices.DispId(61)]
public EnvDTE.CodeElements ImplementedInterfaces { [System.Runtime.InteropServices.DispId(61)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(61)>]
[<get: System.Runtime.InteropServices.DispId(61)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.ImplementedInterfaces : EnvDTE.CodeElements
Public ReadOnly Property ImplementedInterfaces As CodeElements

Property Value

A CodeElements collection.

Attributes

Examples

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

        ' Display the class's implemented interfaces.  
        Dim ifaces As String  
        Dim iface As CodeInterface  
        For Each iface In cls.ImplementedInterfaces  
            ifaces &= iface.Name & vbCrLf  
        Next  

        MsgBox(cls.Name & " implements the following interfaces:" & _  
            vbCrLf & vbCrLf & ifaces)  
    Catch ex As Exception  
        MsgBox(ex.Message)  
    End Try  

End Sub  
public void ImplementedInterfacesExample(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);  

        // Display the class's implemented interfaces.  
        string ifaces = "";  

        foreach (CodeInterface iface in cls.ImplementedInterfaces)  
            ifaces += iface.Name + "\n";  

        MessageBox.Show(cls.Name +   
            " implements the following interfaces:\n\n" + ifaces);  
    }  
    catch (Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Remarks

ImplementedInterfaces returns a CodeElements collection, each element of type vsCMElementInterface (see vsCMElement) and representing an interface implemented by the code class.

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).

Applies to