Sdílet prostřednictvím


CodeClass2.Bases – vlastnost

Získá kolekce tříd, z něhož pochází tento kód třídy.

Obor názvů:  EnvDTE80
Sestavení:  EnvDTE80 (v EnvDTE80.dll)

Syntaxe

'Deklarace
ReadOnly Property Bases As CodeElements
    Get
CodeElements Bases { get; }
property CodeElements^ Bases {
    CodeElements^ get ();
}
abstract Bases : CodeElements
function get Bases () : CodeElements

Hodnota vlastnosti

Typ: EnvDTE.CodeElements
A CodeElements kolekce.

Implementuje

CodeClass.Bases

Poznámky

Super typy jsou CodeElements. Visual Basic a Visual C#, je vždy pouze jeden prvek v kolekci, kromě případů, kdy je typ kódu CodeInterface nebo CodeInterface2.

Poznámka

Deterministický může být po provedení určité typy úprav, což znamená, že jejich hodnoty nelze dovolávat vždy zůstat stejné hodnoty prvků modelu kód jako třídy, struktury, funkce, atributy, delegátů a tak dále. Další informace naleznete v části Změna hodnoty prvku modelu kódu Discovering Code by Using the Code Model (Visual Basic).

Příklady

Visual Basic

Sub BasesExample(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 CodeClass2 = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementClass), CodeClass2)

        ' Enumerate the CodeClass's bases.
        Dim bases As String = ""
        Dim elem As CodeElement2
        For Each elem In cls.Bases
            bases &= elem.FullName & vbCrLf
        Next

        MsgBox(cls.Name & " has the following bases:" & _
            vbCrLf & vbCrLf & bases)
    Catch ex As System.Exception
        MsgBox(ex.Message)
    End Try
End Sub

[C#]

public void BasesExample(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;
        CodeClass2 cls = 
            (CodeClass)sel.ActivePoint.get_CodeElement2(
            vsCMElement.vsCMElementClass);

        // Enumerate the CodeClass's bases.
        string bases = "";
        foreach (CodeElement2 elem in cls.Bases)
        {
        bases += elem.FullName + Environment.NewLine;
        }

        MessageBox.Show(cls.Name + " has the following bases:" + 
            Environment.NewLine + Environment.NewLine + bases);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

CodeClass2 Rozhraní

Bases – přetížení

EnvDTE80 – obor názvů

Další zdroje

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

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)