NSoft.NFramework.Tools.TypeTool.GetTypeDefaultValue C# (CSharp) Method

GetTypeDefaultValue() public static method

특정 수형의 기본값을 반환합니다. ValueType인 경우는 기본 생성자를 통해 값을 반환하고, ValueType이 아닌 경우에는 null을 반환합니다.
public static GetTypeDefaultValue ( this type ) : object
type this
return object
        public static object GetTypeDefaultValue(this Type type) {
            if(type == null)
                return null;

            if(IsDebugEnabled)
                log.Debug("특정 수형[{0}]의 기본값을 구합니다...", type.FullName);

            object result = null;

            if(type.IsValueType)
                result = ActivatorTool.CreateInstance(type);

            if(IsDebugEnabled)
                log.Debug("특정 수형[{0}]의 기본값=[{1}] 입니다.", type.FullName, result ?? "null");

            return result;
        }