Ejemplo n.º 1
0
        public static object DefaultValue(Type type)
        {
            if (type == typeof(string))
            {
                return("");
            }

            if (type.IsArray)
            {
                return(Activator.CreateInstance(type, 0));
            }

            if (type.IsInterface)
            {
                return(DtoFactory.Dto(type));
            }

            //Nullable available 0 default
            if (type.Name == typeof(int?).Name)
            {
                var argType = type.GenericTypeArguments[0];
                if (s_availableZeroTypes.Contains(argType))
                {
                    return(Convert.ChangeType(0, argType));
                }
            }

            return(Activator.CreateInstance(type));
        }
Ejemplo n.º 2
0
 public TSource CreateDto <TSource>()
 {
     return(DtoFactory.Dto <TSource>());
 }