public static void SetDateTimeValue(this ICdlValueWriter writer, TypeStorage type, DateTimeEx value) { switch (type) { case TypeStorage.DateEx: writer.SetDateEx(value.DatePart); break; case TypeStorage.TimeEx: writer.SetTimeEx(value.TimePart); break; case TypeStorage.DateTime: writer.SetDateTime(value.AsDateTime); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(value); break; } }
public static void ReadValue(SQLiteDataReader reader, int index, TypeStorage type, ICdlValueWriter writer) { switch (type) { case TypeStorage.Boolean: writer.SetBoolean(reader.GetInt32(index) != 0); break; case TypeStorage.Byte: writer.SetByte((byte) reader.GetInt32(index)); break; case TypeStorage.Int16: writer.SetInt16((short) reader.GetInt32(index)); break; case TypeStorage.Int32: writer.SetInt32((int) reader.GetInt32(index)); break; case TypeStorage.Int64: writer.SetInt64((long) reader.GetInt64(index)); break; case TypeStorage.SByte: writer.SetSByte((sbyte) reader.GetInt32(index)); break; case TypeStorage.UInt16: writer.SetUInt16((ushort) reader.GetInt32(index)); break; case TypeStorage.UInt32: writer.SetUInt32((uint) reader.GetInt32(index)); break; case TypeStorage.UInt64: writer.SetUInt64((ulong) reader.GetInt64(index)); break; case TypeStorage.DateTime: writer.SetDateTime(DateTime.Parse(reader.GetString(index), CultureInfo.InvariantCulture)); //writer.SetDateTime(DateTime.ParseExact(reader.GetString(index), "s", CultureInfo.InvariantCulture)); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(DateTimeEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.DateEx: writer.SetDateEx(DateEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.TimeEx: writer.SetTimeEx(TimeEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.Decimal: { var dtype = reader.GetFieldType(index); decimal value; if (dtype == typeof (string)) { value = Decimal.Parse(reader.GetString(index), CultureInfo.InvariantCulture); } else { value = (decimal) reader.GetDouble(index); } writer.SetDecimal(value); } break; case TypeStorage.Float: writer.SetFloat((float) reader.GetDouble(index)); break; case TypeStorage.Double: writer.SetDouble((double) reader.GetDouble(index)); break; case TypeStorage.String: writer.SetString(reader.GetString(index)); break; case TypeStorage.Guid: writer.SetGuid(new Guid(reader.GetString(index))); break; case TypeStorage.ByteArray: writer.SetByteArray((byte[]) reader.GetValue(index)); break; case TypeStorage.Null: writer.SetNull(); break; default: throw new Exception("DBSH-00167 Unsupported field type:" + type.ToString()); } }
public static void ReadValue(SQLiteDataReader reader, int index, TypeStorage type, ICdlValueWriter writer) { switch (type) { case TypeStorage.Boolean: writer.SetBoolean(reader.GetInt32(index) != 0); break; case TypeStorage.Byte: writer.SetByte((byte)reader.GetInt32(index)); break; case TypeStorage.Int16: writer.SetInt16((short)reader.GetInt32(index)); break; case TypeStorage.Int32: writer.SetInt32((int)reader.GetInt32(index)); break; case TypeStorage.Int64: writer.SetInt64((long)reader.GetInt64(index)); break; case TypeStorage.SByte: writer.SetSByte((sbyte)reader.GetInt32(index)); break; case TypeStorage.UInt16: writer.SetUInt16((ushort)reader.GetInt32(index)); break; case TypeStorage.UInt32: writer.SetUInt32((uint)reader.GetInt32(index)); break; case TypeStorage.UInt64: writer.SetUInt64((ulong)reader.GetInt64(index)); break; case TypeStorage.DateTime: writer.SetDateTime(DateTime.Parse(reader.GetString(index), CultureInfo.InvariantCulture)); //writer.SetDateTime(DateTime.ParseExact(reader.GetString(index), "s", CultureInfo.InvariantCulture)); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(DateTimeEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.DateEx: writer.SetDateEx(DateEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.TimeEx: writer.SetTimeEx(TimeEx.ParseNormalized(reader.GetString(index))); break; case TypeStorage.Decimal: { var dtype = reader.GetFieldType(index); decimal value; if (dtype == typeof(string)) { value = Decimal.Parse(reader.GetString(index), CultureInfo.InvariantCulture); } else { value = (decimal)reader.GetDouble(index); } writer.SetDecimal(value); } break; case TypeStorage.Float: writer.SetFloat((float)reader.GetDouble(index)); break; case TypeStorage.Double: writer.SetDouble((double)reader.GetDouble(index)); break; case TypeStorage.String: writer.SetString(reader.GetString(index)); break; case TypeStorage.Guid: writer.SetGuid(new Guid(reader.GetString(index))); break; case TypeStorage.ByteArray: writer.SetByteArray((byte[])reader.GetValue(index)); break; case TypeStorage.Null: writer.SetNull(); break; default: throw new Exception("DBSH-00167 Unsupported field type:" + type.ToString()); } }
public void ParseValue(string text, TypeStorage type, ICdlValueWriter writer) { foreach (string nulltext in m_settings.GetNullValues()) { if (text == nulltext) { writer.SetNull(); return; } } NumberStyles floatStyle = NumberStyles.Float | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowExponent; NumberStyles intStyle = NumberStyles.Integer | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite; NumberStyles decStyle = NumberStyles.Number | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowExponent; switch (type) { case TypeStorage.Null: writer.SetNull(); break; case TypeStorage.Boolean: { if (IsNullTextTest(text)) { writer.SetNull(); } else { bool? val = m_settings.ParseBoolean(text); if (val != null) writer.SetBoolean(val.Value); else writer.SetNull(); } } break; case TypeStorage.Byte: { byte val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Byte.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetByte(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int16: { short val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int16.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt16(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int32: { int val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int32.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt32(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int64: { long val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int64.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt64(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.SByte: { sbyte val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (SByte.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetSByte(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt16: { ushort val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt16.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt16(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt32: { uint val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt32.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt32(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt64: { ulong val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt64.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt64(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Float: { float val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Single.TryParse(text, floatStyle, m_numberFormat, out val)) { writer.SetFloat(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Double: { double val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Double.TryParse(text, floatStyle, m_numberFormat, out val)) { writer.SetDouble(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Decimal: { decimal val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Decimal.TryParse(text, decStyle, m_numberFormat, out val)) { writer.SetDecimal(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.DateTime: { DateTime val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (DateTime.TryParseExact(text, m_settings.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out val)) { writer.SetDateTime(val); } else if (DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out val)) { writer.SetDateTime(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.DateTimeEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetDateTimeEx(DateTimeEx.Parse(text, m_settings.DateTimeFormat, CultureInfo.InvariantCulture)); } catch { writer.SetDateTimeEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture))); } } break; case TypeStorage.DateEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetDateEx(DateTimeEx.Parse(text, m_settings.DateFormat, CultureInfo.InvariantCulture).DatePart); } catch { writer.SetDateEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture)).DatePart); } } break; case TypeStorage.TimeEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetTimeEx(DateTimeEx.Parse(text, m_settings.TimeFormat, CultureInfo.InvariantCulture).TimePart); } catch { writer.SetTimeEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture)).TimePart); } } break; case TypeStorage.ByteArray: if (IsNullTextTest(text)) { writer.SetNull(); } else if (text.EndsWith("=")) { writer.SetByteArray(Convert.FromBase64String(text.Replace("=", ""))); } else { writer.SetNull(); } break; case TypeStorage.Guid: if (IsNullTextTest(text)) { writer.SetNull(); } else { writer.SetGuid(new Guid(text)); } break; case TypeStorage.String: writer.SetString(text); break; //case TypeStorage.Array: // writer.SetArray(CdlArray.Parse(text)); // break; } }
public static void ReadValue(this ICdlValueWriter writer, BinaryReader stream) { TypeStorage storage = (TypeStorage)stream.ReadByte(); switch (storage) { case TypeStorage.Null: writer.SetNull(); break; case TypeStorage.Boolean: writer.SetBoolean(stream.ReadBoolean()); break; case TypeStorage.Byte: writer.SetByte(stream.ReadByte()); break; case TypeStorage.Int16: writer.SetInt16(stream.ReadInt16()); break; case TypeStorage.Int32: writer.SetInt32(stream.ReadInt32()); break; case TypeStorage.Int64: writer.SetInt64(stream.ReadInt64()); break; case TypeStorage.SByte: writer.SetSByte(stream.ReadSByte()); break; case TypeStorage.UInt16: writer.SetUInt16(stream.ReadUInt16()); break; case TypeStorage.UInt32: writer.SetUInt32(stream.ReadUInt32()); break; case TypeStorage.UInt64: writer.SetUInt64(stream.ReadUInt64()); break; case TypeStorage.Float: writer.SetFloat(stream.ReadSingle()); break; case TypeStorage.Double: writer.SetDouble(stream.ReadDouble()); break; case TypeStorage.Decimal: writer.SetDecimal(stream.ReadDecimal()); break; case TypeStorage.DateTime: writer.SetDateTime(DateTime.FromBinary(stream.ReadInt64())); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(DateTimeEx.FromStream(stream)); break; case TypeStorage.DateEx: writer.SetDateEx(DateEx.FromStream(stream)); break; case TypeStorage.TimeEx: writer.SetTimeEx(TimeEx.FromStream(stream)); break; case TypeStorage.ByteArray: { int len = stream.Read7BitEncodedInteger(); writer.SetByteArray(stream.ReadBytes(len)); } break; case TypeStorage.Guid: writer.SetGuid(new Guid(stream.ReadBytes(16))); break; case TypeStorage.String: writer.SetString(stream.ReadString()); break; } }
public static void WriteTo(this ICdlValueReader reader, ICdlValueWriter writer) { switch (reader.GetFieldType()) { case TypeStorage.Null: writer.SetNull(); break; case TypeStorage.Boolean: writer.SetBoolean(reader.GetBoolean()); break; case TypeStorage.Byte: writer.SetByte(reader.GetByte()); break; case TypeStorage.Int16: writer.SetInt16(reader.GetInt16()); break; case TypeStorage.Int32: writer.SetInt32(reader.GetInt32()); break; case TypeStorage.Int64: writer.SetInt64(reader.GetInt64()); break; case TypeStorage.SByte: writer.SetSByte(reader.GetSByte()); break; case TypeStorage.UInt16: writer.SetUInt16(reader.GetUInt16()); break; case TypeStorage.UInt32: writer.SetUInt32(reader.GetUInt32()); break; case TypeStorage.UInt64: writer.SetUInt64(reader.GetUInt64()); break; case TypeStorage.Float: writer.SetFloat(reader.GetFloat()); break; case TypeStorage.Double: writer.SetDouble(reader.GetDouble()); break; case TypeStorage.Decimal: writer.SetDecimal(reader.GetDecimal()); break; case TypeStorage.DateTime: writer.SetDateTime(reader.GetDateTime()); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(reader.GetDateTimeEx()); break; case TypeStorage.DateEx: writer.SetDateEx(reader.GetDateEx()); break; case TypeStorage.TimeEx: writer.SetTimeEx(reader.GetTimeEx()); break; case TypeStorage.ByteArray: writer.SetByteArray(reader.GetByteArray()); break; case TypeStorage.Guid: writer.SetGuid(reader.GetGuid()); break; case TypeStorage.String: writer.SetString(reader.GetString()); break; } }
public static void ReadFrom(this ICdlValueWriter writer, object value) { if (value == null || value == DBNull.Value) { writer.SetNull(); return; } var valreader = value as ICdlValueReader; if (valreader != null) { writer.ReadFrom(valreader); return; } Type type = value.GetType(); switch (Type.GetTypeCode(type)) { case TypeCode.Boolean: writer.SetBoolean((bool)value); break; case TypeCode.Byte: writer.SetByte((byte)value); break; case TypeCode.Int16: writer.SetInt16((short)value); break; case TypeCode.Int32: writer.SetInt32((int)value); break; case TypeCode.Int64: writer.SetInt64((long)value); break; case TypeCode.SByte: writer.SetSByte((sbyte)value); break; case TypeCode.UInt16: writer.SetUInt16((ushort)value); break; case TypeCode.UInt32: writer.SetUInt32((uint)value); break; case TypeCode.UInt64: writer.SetUInt64((ulong)value); break; case TypeCode.DateTime: writer.SetDateTime((DateTime)value); break; case TypeCode.Decimal: writer.SetDecimal((decimal)value); break; case TypeCode.Single: writer.SetFloat((float)value); break; case TypeCode.Double: writer.SetDouble((double)value); break; case TypeCode.String: writer.SetString((string)value); break; default: if (type == typeof(Guid)) { writer.SetGuid((Guid)value); } else if (type == typeof(byte[])) { writer.SetByteArray((byte[])value); } else if (type == typeof(DateTimeEx)) { writer.SetDateTimeEx((DateTimeEx)value); } else if (type == typeof(DateEx)) { writer.SetDateEx((DateEx)value); } else if (type == typeof(TimeEx)) { writer.SetTimeEx((TimeEx)value); } else { writer.SetString(value.ToString()); } break; } }
public static void ReadFrom(this ICdlValueWriter writer, IDataRecord record, int index) { if (record.IsDBNull(index)) { writer.SetNull(); return; } Type type = record.GetFieldType(index); try { switch (Type.GetTypeCode(type)) { case TypeCode.Boolean: writer.SetBoolean(record.GetBoolean(index)); break; case TypeCode.Byte: writer.SetByte(record.GetByte(index)); break; case TypeCode.Int16: writer.SetInt16(record.GetInt16(index)); break; case TypeCode.Int32: writer.SetInt32(record.GetInt32(index)); break; case TypeCode.Int64: writer.SetInt64(record.GetInt64(index)); break; case TypeCode.SByte: unchecked { writer.SetSByte((sbyte)record.GetByte(index)); } break; case TypeCode.UInt16: unchecked { writer.SetUInt16((ushort)record.GetInt16(index)); } break; case TypeCode.UInt32: unchecked { writer.SetUInt32((uint)record.GetInt32(index)); } break; case TypeCode.UInt64: unchecked { writer.SetUInt64((ulong)record.GetInt64(index)); } break; case TypeCode.DateTime: writer.SetDateTime(record.GetDateTime(index)); break; case TypeCode.Decimal: writer.SetDecimal(record.GetDecimal(index)); break; case TypeCode.Single: writer.SetFloat(record.GetFloat(index)); break; case TypeCode.Double: writer.SetDouble(record.GetDouble(index)); break; case TypeCode.String: writer.SetString(record.GetString(index)); break; default: if (type == typeof(Guid)) { writer.SetGuid(record.GetGuid(index)); } else if (type == typeof(byte[])) { writer.SetByteArray((byte[])record.GetValue(index)); } else { writer.SetString(record.GetValue(index).ToString()); } break; } } catch (Exception err) { try { object val = record[index]; // try to read from boxed value (not very effective) writer.ReadFrom(val); } catch { try { writer.SetString(record.GetString(index)); } catch { // add information to exception try { err.Data["data_type"] = record.GetFieldType(index).FullName; } catch (Exception err2) { err.Data["data_type"] = err2.ToString(); } try { err.Data["data_isnull"] = record.IsDBNull(index).ToString(); } catch (Exception err2) { err.Data["data_isnull"] = err2.ToString(); } throw err; } } } }
public static void WriteTo(this ICdlValueReader reader, ICdlValueWriter writer) { switch (reader.GetFieldType()) { case TypeStorage.Null: writer.SetNull(); break; case TypeStorage.Boolean: writer.SetBoolean(reader.GetBoolean()); break; case TypeStorage.Byte: writer.SetByte(reader.GetByte()); break; case TypeStorage.Int16: writer.SetInt16(reader.GetInt16()); break; case TypeStorage.Int32: writer.SetInt32(reader.GetInt32()); break; case TypeStorage.Int64: writer.SetInt64(reader.GetInt64()); break; case TypeStorage.SByte: writer.SetSByte(reader.GetSByte()); break; case TypeStorage.UInt16: writer.SetUInt16(reader.GetUInt16()); break; case TypeStorage.UInt32: writer.SetUInt32(reader.GetUInt32()); break; case TypeStorage.UInt64: writer.SetUInt64(reader.GetUInt64()); break; case TypeStorage.Float: writer.SetFloat(reader.GetFloat()); break; case TypeStorage.Double: writer.SetDouble(reader.GetDouble()); break; case TypeStorage.Decimal: writer.SetDecimal(reader.GetDecimal()); break; case TypeStorage.DateTime: writer.SetDateTime(reader.GetDateTime()); break; case TypeStorage.DateTimeEx: writer.SetDateTimeEx(reader.GetDateTimeEx()); break; case TypeStorage.DateEx: writer.SetDateEx(reader.GetDateEx()); break; case TypeStorage.TimeEx: writer.SetTimeEx(reader.GetTimeEx()); break; case TypeStorage.ByteArray: writer.SetByteArray(reader.GetByteArray()); break; case TypeStorage.Guid: writer.SetGuid(reader.GetGuid()); break; case TypeStorage.String: writer.SetString(reader.GetString()); break; } }
public void ParseValue(string text, TypeStorage type, ICdlValueWriter writer) { foreach (string nulltext in m_settings.GetNullValues()) { if (text == nulltext) { writer.SetNull(); return; } } NumberStyles floatStyle = NumberStyles.Float | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowExponent; NumberStyles intStyle = NumberStyles.Integer | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite; NumberStyles decStyle = NumberStyles.Number | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowExponent; switch (type) { case TypeStorage.Null: writer.SetNull(); break; case TypeStorage.Boolean: { if (IsNullTextTest(text)) { writer.SetNull(); } else { bool?val = m_settings.ParseBoolean(text); if (val != null) { writer.SetBoolean(val.Value); } else { writer.SetNull(); } } } break; case TypeStorage.Byte: { byte val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Byte.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetByte(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int16: { short val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int16.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt16(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int32: { int val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int32.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt32(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Int64: { long val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Int64.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetInt64(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.SByte: { sbyte val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (SByte.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetSByte(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt16: { ushort val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt16.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt16(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt32: { uint val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt32.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt32(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.UInt64: { ulong val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (UInt64.TryParse(text, intStyle, m_numberFormat, out val)) { writer.SetUInt64(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Float: { float val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Single.TryParse(text, floatStyle, m_numberFormat, out val)) { writer.SetFloat(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Double: { double val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Double.TryParse(text, floatStyle, m_numberFormat, out val)) { writer.SetDouble(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.Decimal: { decimal val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (Decimal.TryParse(text, decStyle, m_numberFormat, out val)) { writer.SetDecimal(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.DateTime: { DateTime val; if (IsNullTextTest(text)) { writer.SetNull(); } else if (DateTime.TryParseExact(text, m_settings.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out val)) { writer.SetDateTime(val); } else if (DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out val)) { writer.SetDateTime(val); } else { ParseError(text, type, writer); } } break; case TypeStorage.DateTimeEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetDateTimeEx(DateTimeEx.Parse(text, m_settings.DateTimeFormat, CultureInfo.InvariantCulture)); } catch { writer.SetDateTimeEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture))); } } break; case TypeStorage.DateEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetDateEx(DateTimeEx.Parse(text, m_settings.DateFormat, CultureInfo.InvariantCulture).DatePart); } catch { writer.SetDateEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture)).DatePart); } } break; case TypeStorage.TimeEx: if (IsNullTextTest(text)) { writer.SetNull(); } else { try { writer.SetTimeEx(DateTimeEx.Parse(text, m_settings.TimeFormat, CultureInfo.InvariantCulture).TimePart); } catch { writer.SetTimeEx(DateTimeEx.FromDateTime(DateTime.Parse(text, CultureInfo.InvariantCulture)).TimePart); } } break; case TypeStorage.ByteArray: if (IsNullTextTest(text)) { writer.SetNull(); } else if (Regex.Match(text, @"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$").Success) { writer.SetByteArray(Convert.FromBase64String(text)); } else { writer.SetNull(); } break; case TypeStorage.Guid: if (IsNullTextTest(text)) { writer.SetNull(); } else { writer.SetGuid(new Guid(text)); } break; case TypeStorage.String: writer.SetString(text); break; //case TypeStorage.Array: // writer.SetArray(CdlArray.Parse(text)); // break; } }