Właściwość CodeClass.DerivedTypes —
Zwraca kolekcję obiektów pochodzących z tego CodeClass obiektu.Nie zaimplementowane w środowisku Visual C#.
Przestrzeń nazw: EnvDTE
Zestaw: EnvDTE (w EnvDTE.dll)
Składnia
'Deklaracja
ReadOnly Property DerivedTypes As CodeElements
CodeElements DerivedTypes { get; }
property CodeElements^ DerivedTypes {
CodeElements^ get ();
}
abstract DerivedTypes : CodeElements with get
function get DerivedTypes () : CodeElements
Wartość właściwości
Typ: EnvDTE.CodeElements
A CodeElements kolekcji.
Uwagi
DerivedTypesZwraca CodeElements kolekcją typów, które wynikają z tego CodeClass.DerivedTypesZwraca tylko typy, które wynikają z CodeClass w ramach pojedynczego projektu, nie tylko w innych projektów lub języków.Jeśli element kodu jest vsCMElementInterface, a następnie zwrócone kolekcja zawiera również CodeClass obiektów, które implementują interfejs.
[!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 DerivedTypesExample(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 namespace's children.
Dim types As String
Dim elem As CodeElement
For Each elem In cls.DerivedTypes
types &= elem.Name & vbCrLf
Next
MsgBox(cls.Name & " has the following derived types:" & _
vbCrLf & vbCrLf & types)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void DerivedTypesExample(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 namespace's children.
string types = "";
foreach (CodeElement elem in cls.DerivedTypes)
types += elem.Name + "\r\n";
MessageBox.Show(cls.Name +
" has the following derived types:\r\n\r\n" + types);
}
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