private object ImportDefaultValue(TypeMapping mapping, string defaultValue) { if (defaultValue == null) { return(null); } if (mapping is PrimitiveMapping) { if (mapping is EnumMapping) { EnumMapping mapping2 = (EnumMapping)mapping; ConstantMapping[] constants = mapping2.Constants; if (mapping2.IsFlags) { Hashtable vals = new Hashtable(); string[] strArray = new string[constants.Length]; long[] ids = new long[constants.Length]; for (int j = 0; j < constants.Length; j++) { ids[j] = mapping2.IsFlags ? (((long)1L) << j) : ((long)j); strArray[j] = constants[j].Name; vals.Add(constants[j].Name, ids[j]); } return(XmlCustomFormatter.FromEnum(XmlCustomFormatter.ToEnum(defaultValue, vals, mapping2.TypeName, true), strArray, ids, mapping2.TypeDesc.FullName)); } for (int i = 0; i < constants.Length; i++) { if (constants[i].XmlName == defaultValue) { return(constants[i].Name); } } throw new InvalidOperationException(Res.GetString("XmlInvalidDefaultValue", new object[] { defaultValue, mapping2.TypeDesc.FullName })); } PrimitiveMapping mapping3 = (PrimitiveMapping)mapping; if (!mapping3.TypeDesc.HasCustomFormatter) { if (mapping3.TypeDesc.FormatterName == "String") { return(defaultValue); } if (mapping3.TypeDesc.FormatterName == "DateTime") { return(XmlCustomFormatter.ToDateTime(defaultValue)); } Type type = typeof(XmlConvert); MethodInfo method = type.GetMethod("To" + mapping3.TypeDesc.FormatterName, new Type[] { typeof(string) }); if (method != null) { return(method.Invoke(type, new object[] { defaultValue })); } } else if (mapping3.TypeDesc.HasDefaultSupport) { return(XmlCustomFormatter.ToDefaultValue(defaultValue, mapping3.TypeDesc.FormatterName)); } } return(DBNull.Value); }