다음을 통해 공유


CodeClass2.DerivedTypes 속성

코드 클래스에서 파생되는 개체의 컬렉션을 가져옵니다. Visual C#에는 구현되어 있지 않습니다.

네임스페이스:  EnvDTE80
어셈블리:  EnvDTE80(EnvDTE80.dll)

구문

‘선언
ReadOnly Property DerivedTypes As CodeElements
CodeElements DerivedTypes { get; }
property CodeElements^ DerivedTypes {
    CodeElements^ get ();
}
abstract DerivedTypes : CodeElements with get
function get DerivedTypes () : CodeElements

속성 값

형식: CodeElements
CodeElements 컬렉션입니다.

설명

DerivedTypes 속성은 코드 클래스에서 파생되는 형식의 CodeElements 컬렉션을 반환합니다. DerivedTypes 컬렉션은 단일 프로젝트 내에서 코드 클래스로부터 파생된 형식만 반환하며, 다른 프로젝트나 언어에 대해서는 반환하지 않습니다. 코드 요소가 vsCMElementInterface이면 반환된 컬렉션에는 인터페이스를 구현하는 CodeClass 개체도 포함됩니다.

참고

클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소를 특정한 방식으로 편집한 후에는 요소의 값이 명확하지 않을 수 있습니다. 즉, 요소의 값이 항상 같다고 할 수 없습니다.자세한 내용은 코드 모델을 사용하여 코드 검색(Visual Basic)의 "코드 모델 요소 값이 변경될 수 있음" 단원을 참조하십시오.

예제

[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

[C#]

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 보안

참고 항목

참조

CodeClass2 인터페이스

EnvDTE80 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행

코드 모델을 사용하여 코드 검색(Visual Basic)

코드 모델을 사용하여 코드 검색(Visual C#)