public static DateTimeEx GetDateTimeValue(this IBedValueReader reader) { switch (reader.GetFieldType()) { case TypeStorage.DateEx: return(new DateTimeEx { DatePart = reader.GetDateEx() }); case TypeStorage.TimeEx: return(new DateTimeEx { TimePart = reader.GetTimeEx() }); case TypeStorage.DateTime: return(new DateTimeEx { AsDateTime = reader.GetDateTime() }); case TypeStorage.DateTimeEx: return(reader.GetDateTimeEx()); default: return(new DateTimeEx()); } }
//public static void WriteTo(this IBedValueReader reader, BinaryWriter stream) //{ // switch (reader.GetFieldType()) // { // case TypeStorage.Null: // stream.Write((byte)TypeStorage.Null); // break; // case TypeStorage.Boolean: // stream.Write((byte)TypeStorage.Boolean); // stream.Write(reader.GetBoolean()); // break; // case TypeStorage.Byte: // stream.Write((byte)TypeStorage.Byte); // stream.Write(reader.GetByte()); // break; // case TypeStorage.Int16: // stream.Write((byte)TypeStorage.Int16); // stream.Write(reader.GetInt16()); // break; // case TypeStorage.Int32: // stream.Write((byte)TypeStorage.Int32); // stream.Write(reader.GetInt32()); // break; // case TypeStorage.Int64: // stream.Write((byte)TypeStorage.Int64); // stream.Write(reader.GetInt64()); // break; // case TypeStorage.Float: // stream.Write((byte)TypeStorage.Float); // stream.Write(reader.GetFloat()); // break; // case TypeStorage.Double: // stream.Write((byte)TypeStorage.Double); // stream.Write(reader.GetDouble()); // break; // case TypeStorage.Decimal: // stream.Write((byte)TypeStorage.Decimal); // stream.Write(reader.GetDecimal()); // break; // case TypeStorage.DateTime: // stream.Write((byte)TypeStorage.DateTime); // stream.Write(reader.GetDateTime().ToBinary()); // break; // case TypeStorage.DateTimeEx: // stream.Write((byte)TypeStorage.DateTime); // reader.GetDateTimeEx().WriteTo(stream); // break; // case TypeStorage.ByteArray: // { // byte[] val = reader.GetByteArray(); // stream.Write((byte)TypeStorage.ByteArray); // stream.Write7BitEncodedInt(val.Length); // stream.Write(val); // } // break; // case TypeStorage.Guid: // stream.Write((byte)TypeStorage.Guid); // stream.Write(reader.GetGuid().ToByteArray()); // break; // case TypeStorage.String: // stream.Write((byte)TypeStorage.String); // stream.Write(reader.GetString()); // break; // } //} public static void WriteTo(this IBedValueReader reader, IBedValueWriter 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; //case TypeStorage.Array: // writer.SetArray(reader.GetArray()); // break; } }
public static object BoxTypedValue(this IBedValueReader reader) { switch (reader.GetFieldType()) { case TypeStorage.Null: return(null); case TypeStorage.Boolean: return(reader.GetBoolean()); case TypeStorage.Byte: return(reader.GetByte()); case TypeStorage.Int16: return(reader.GetInt16()); case TypeStorage.Int32: return(reader.GetInt32()); case TypeStorage.Int64: return(reader.GetInt64()); case TypeStorage.SByte: return(reader.GetSByte()); case TypeStorage.UInt16: return(reader.GetUInt16()); case TypeStorage.UInt32: return(reader.GetUInt32()); case TypeStorage.UInt64: return(reader.GetUInt64()); case TypeStorage.Float: return(reader.GetFloat()); case TypeStorage.Double: return(reader.GetDouble()); case TypeStorage.Decimal: return(reader.GetDecimal()); case TypeStorage.DateTime: return(reader.GetDateTime()); case TypeStorage.DateTimeEx: return(reader.GetDateTimeEx()); case TypeStorage.DateEx: return(reader.GetDateEx()); case TypeStorage.TimeEx: return(reader.GetTimeEx()); case TypeStorage.ByteArray: return(reader.GetByteArray()); case TypeStorage.Guid: return(reader.GetGuid()); case TypeStorage.String: return(reader.GetString()); //case TypeStorage.Array: // return reader.GetArray(); } return(null); }
public static bool GetValueAsXml(IBedValueReader rec, ref string xtype, ref string xdata) { var type = rec.GetFieldType(); if (type == TypeStorage.Null) { return(false); } switch (type) { case TypeStorage.Boolean: xtype = "bool"; xdata = rec.GetBoolean() ? "1" : "0"; break; case TypeStorage.Byte: xtype = "byte"; xdata = rec.GetByte().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.Int16: xtype = "i16"; xdata = rec.GetInt16().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.Int32: xtype = "i32"; xdata = rec.GetInt32().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.Int64: xtype = "i64"; xdata = rec.GetInt64().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.SByte: xtype = "sbyte"; xdata = rec.GetSByte().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.UInt16: xtype = "u16"; xdata = rec.GetUInt16().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.UInt32: xtype = "u32"; xdata = rec.GetUInt32().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.UInt64: xtype = "u64"; xdata = rec.GetUInt64().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.DateTime: xtype = "datetime"; xdata = rec.GetDateTime().ToString("s", CultureInfo.InvariantCulture); break; case TypeStorage.DateTimeEx: xtype = "dtex"; xdata = rec.GetDateTimeEx().ToStringNormalized(); break; case TypeStorage.DateEx: xtype = "date"; xdata = rec.GetDateEx().ToStringNormalized(); break; case TypeStorage.TimeEx: xtype = "time"; xdata = rec.GetTimeEx().ToStringNormalized(); break; case TypeStorage.Decimal: xtype = "decimal"; xdata = rec.GetDecimal().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.Float: xtype = "float"; xdata = rec.GetFloat().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.Double: xtype = "double"; xdata = rec.GetDouble().ToString(CultureInfo.InvariantCulture); break; case TypeStorage.String: xtype = "str"; xdata = rec.GetString(); break; case TypeStorage.Guid: xtype = "guid"; xdata = rec.GetGuid().ToString(); break; case TypeStorage.ByteArray: { xtype = "blob"; byte[] data = rec.GetByteArray(); xdata = Convert.ToBase64String(data); } break; //case TypeStorage.Array: // { // xtype = "array"; // xdata = BedArray.ToString(rec.GetArray()); // } // break; } return(true); }