첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

▶ 클래스 계층도 만들기 예제

using System;
using System.Collections.Generic;

...

Type rootType = typeof(Object);

List<Type> descendentTypeList = GetDescendentTypeList(rootType); // '자손 타입 리스트 구하기' 참조

ClassInfo rootClassInfo = new ClassInfo(rootType);

BuildClassHierarchy(rootClassInfo, descendentTypeList);

 

728x90

 

▶ 클래스 계층도 만들기

using System;
using System.Collections.Generic;

#region 클래스 계층도 만들기 - BuildClassHierarchy(parentClassInfo, descendentTypeList)

/// <summary>
/// 클래스 계층도 만들기
/// </summary>
/// <param name="parentClassInfo">부모 클래스 정보</param>
/// <param name="descendentTypeList">자손 타입 리스트</param>
public void BuildClassHierarchy(ClassInfo parentClassInfo, List<Type> descendentTypeList)
{
    foreach(Type descendentType in descendentTypeList)
    {
        Type parentType = descendentType.GetTypeInfo().BaseType;

        if(parentType == parentClassInfo.Type)
        {
            ClassInfo classInfo = new ClassInfo(descendentType);

            parentClassInfo.ChildClassInfoList.Add(classInfo);

            BuildClassHierarchy(classInfo, descendentTypeList);
        }
    }
}

#endregion
728x90
그리드형(광고전용)
Posted by icodebroker
,