첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System;
using System.Collections.Generic;
using System.Reflection;

#region 속성 정보 딕셔너리 구하기 - GetPropertyInfoDictionary(sourceObject)

/// <summary>
/// 속성 정보 딕셔너리 구하기
/// </summary>
/// <param name="sourceObject">소스 객체</param>
/// <returns>속성 정보 딕셔너리</returns>
public Dictionary<string, PropertyInfo> GetPropertyInfoDictionary(object sourceObject)
{
    if(sourceObject == null)
    {
        return null;
    }

    Type sourceType = sourceObject.GetType();

    PropertyInfo[] propertyInfoArray = sourceType.GetProperties(BindingFlags.Public);

    Dictionary<string, PropertyInfo> dictionary = new Dictionary<string, PropertyInfo>();

    foreach(PropertyInfo propertyInfo in propertyInfoArray)
    {
        dictionary.Add(propertyInfo.Name, propertyInfo);
    }

    return dictionary;
}

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

댓글을 달아 주세요