using System;
using System.Collections.Generic;
using System.Text;

namespace GreenTree.Maschinenbestellungen.Core.Extension
{
    public static class TypeExtension
    {
        /// <summary>
        /// Gets the default value of the given type
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>Default value of value type or NULL for reference type.</returns>
        public static object GetDefaultValue(this Type type)
        {
            if (type.IsValueType && Nullable.GetUnderlyingType(type) == null)
                return Activator.CreateInstance(type);

            return null;
        }
    }
}
