Właściwość CodeClass.Bases —
Zwraca kolekcję klas, z których pochodzi ten element.
Przestrzeń nazw: EnvDTE
Zestaw: EnvDTE (w EnvDTE.dll)
Składnia
'Deklaracja
ReadOnly Property Bases As CodeElements
CodeElements Bases { get; }
property CodeElements^ Bases {
CodeElements^ get ();
}
abstract Bases : CodeElements with get
function get Bases () : CodeElements
Wartość właściwości
Typ: EnvDTE.CodeElements
A CodeElements kolekcji.
Uwagi
Podstawy są typy super CodeElements.Dla języka Visual Basic i Visual C# zawsze istnieje tylko jeden element w kolekcji, z wyjątkiem przypadków, gdy jest typ kodu CodeInterface.
[!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 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 CodeClass = _
CType(sel.ActivePoint.CodeElement( _
vsCMElement.vsCMElementClass), CodeClass)
' Enumerate the CodeClass's bases.
Dim bases As String = ""
Dim elem As CodeElement
For Each elem In cls.Bases
bases &= elem.FullName & vbCrLf
Next
MsgBox(cls.Name & " has the following bases:" & _
vbCrLf & vbCrLf & bases)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
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;
CodeClass cls =
(CodeClass)sel.ActivePoint.get_CodeElement(
vsCMElement.vsCMElementClass);
// Enumerate the CodeClass's bases.
string bases = "";
foreach (CodeElement 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);
}
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Używanie bibliotek pochodzących z częściowo zaufanego kodu.
Zobacz też
Informacje
Inne zasoby
Porady: kompilowanie i uruchamianie kodu modelu obiektów automatyzacji — przykłady