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)); }
public TSource CreateDto <TSource>() { return(DtoFactory.Dto <TSource>()); }