CodeClass.DerivedTypes 屬性

取得從這個 CodeClass 物件衍生的物件集合。 尚未在 Visual C# 中進行實作。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property DerivedTypes As CodeElements
    Get
CodeElements DerivedTypes { get; }
property CodeElements^ DerivedTypes {
    CodeElements^ get ();
}
abstract DerivedTypes : CodeElements
function get DerivedTypes () : CodeElements

屬性值

型別:EnvDTE.CodeElements
CodeElements 集合。

備註

DerivedTypes 會傳回衍生自這個 CodeClassCodeElements 型別集合。 DerivedTypes 只會傳回在單一專案內衍生自 CodeClass 的型別,而不會跨越其他專案或語言。 如果程式碼項目是 vsCMElementInterface,那麼傳回的集合也包括實作該介面的 CodeClass 物件。

注意事項注意事項

在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。 如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。

範例

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);
    }
}

.NET Framework 安全性

請參閱

參考

CodeClass 介面

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例

使用程式碼模型探索程式碼 (Visual Basic)

使用程式碼模型探索程式碼 (Visual C#)