728x90
728x170
using System;
using System.Collections.Generic;
using System.Reflection;
#region 자손 타입 리스트 구하기 - GetDescendentTypeList(parentType)
/// <summary>
/// 자손 타입 리스트 구하기
/// </summary>
/// <param name="parentType">부모 타입</param>
/// <returns>자손 타입 리스트</returns>
public List<Type> GetDescendentTypeList(Type parentType)
{
TypeInfo parentTypeInfo = parentType.GetTypeInfo();
Assembly assembly = parentTypeInfo.Assembly;
List<Type> typeList = new List<Type>();
foreach(Type type in assembly.ExportedTypes)
{
TypeInfo typeInfo = type.GetTypeInfo();
if(typeInfo.IsPublic && parentTypeInfo.IsAssignableFrom(typeInfo))
{
typeList.Add(type);
}
}
typeList.Sort((type1, type2) => { return string.Compare(type1.GetTypeInfo().Name, type2.GetTypeInfo().Name); });
return typeList;
}
#endregion
728x90
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] Thread 클래스 : 클래스 객체를 사용해 인자 전달하기 (0) | 2016.05.05 |
---|---|
[C#/COMMON] Process 클래스 : ProcessorAffinity 속성을 사용해 현재 프로세스의 스레드 실행을 예약할 수 있는 프로세서 설정하기 (0) | 2016.05.05 |
[C#/COMMON] SpeechRecognizer 클래스 : 음성 인식 처리하기 (0) | 2016.02.26 |
[C#/COMMON] SpeechRecognitionEngine 클래스 : InstalledRecognizers 정적 메소드를 사용해 설치된 인식기 나열하기 (0) | 2016.02.26 |
[C#/COMMON] 클래스 계층도 만들기 (0) | 2016.02.06 |
[C#/COMMON] Console 클래스 : ForegroundColor 정적 속성을 사용해 문자열 출력시 색상 설정하기 (0) | 2016.01.28 |
[C#/COMMON] Publish 클래스 : GacInstall 메소드를 사용해 어셈블리 GAC 등록하기 (0) | 2016.01.27 |
[C#/COMMON] SpeechSynthesizer 클래스 : 음성 출력하기 (0) | 2016.01.27 |
[C#/COMMON] SpeechRecognitionEngine 클래스 : 음성 인식 처리하기 (0) | 2016.01.27 |
[C#/COMMON] 닷넷 어셈블리 2.0 버전을 닷넷 4.5 프로젝트에서 사용하기 (0) | 2016.01.25 |