public object ToObject(DbValue item, IMember member) { if (member?.Precision == 4) { return(DateTimeOffset.FromUnixTimeMilliseconds(item.ToInt64()).UtcDateTime); } return(DateTimeOffset.FromUnixTimeSeconds(item.ToInt64()).UtcDateTime); }
public object ToObject(DbValue item, IMember member) { var precision = (TimePrecision)(member?.Precision ?? 0); switch (precision) { case TimePrecision.Millisecond: return(DateTimeOffset.FromUnixTimeMilliseconds(item.ToInt64())); default: return(DateTimeOffset.FromUnixTimeSeconds(item.ToInt64())); } }
public object ToObject(DbValue item, IMember member) { // TODO: Use a nested map switch (item.Kind) { case DbValueType.B: return(StringMap.FromBytes(item.ToBinary())); default: return(new StringMap()); } }
public object ToObject(DbValue item, IMember member) { var precision = (TimePrecision)(member.Precision ?? 3); switch (precision) { case TimePrecision.Second: return(TimeSpan.FromSeconds(item.ToInt())); default: return(TimeSpan.FromMilliseconds(item.ToInt())); } }
public override IPAddress Parse(DbValue item) { switch (item.Kind) { case DbValueType.S: return(IPAddress.Parse(item.ToString())); case DbValueType.B: return(new IPAddress(item.ToBinary())); default: throw new ConversionException($"Cannot DB type: {item.Kind} to IPAddress"); } }
public object ToObject(DbValue item, IMember member) { // Parse strings to allow graceful migration to integers if (item.Kind == DbValueType.S) { return(Enum.Parse(member.Type, item.ToString())); } return(Enum.ToObject(member.Type, item.ToInt())); }
public object ToObject(DbValue item, IMember member) { // Gracefully migrate from number sets to a custom binary serializer that respects order switch (item.Kind) { case DbValueType.NS: return(new Int32List(item.ToArray <int>())); case DbValueType.B: return(Int32List.FromBytes(item.ToBinary())); default: return(new Int32List()); } }
public object ToObject(DbValue item, IMember member) { // Gracefully migrates from StringSets and custom binary provider to a List switch (item.Kind) { case DbValueType.SS: return(new StringList(item.ToStringSet())); case DbValueType.B: return(StringList.FromBytes(item.ToBinary())); case DbValueType.L: return(new StringList(item.ToArray <string>())); default: return(new StringList()); } }
public void SerializeDbValueListTest() { var converter = DbValueConverterFactory.Get(typeof(DbValue[])); var sampleList = new DbValue[2] { new DbValue(true), new DbValue("hello"), }; var converted = converter.FromObject(sampleList, null); Assert.Equal(DbValueType.L, converted.Kind); DbValue[] backToObject = (DbValue[])converter.ToObject(converted, null); Assert.Equal(sampleList[0].Value, backToObject[0].Value); Assert.Equal(sampleList[1].Value, backToObject[1].Value); }
public object ToObject(DbValue item, IMember member) => item.ToSet <T>();
public object ToObject(DbValue item, IMember member) => item.ToStringSet();
// item.ToStringSet().ToArray(); public override string[] Parse(DbValue dbValue) => dbValue.ToArray <string>();
public object ToObject(DbValue item, IMember member) => (AttributeCollection)item.Value;
public override Uid Parse(DbValue item) => Uid.Deserialize(item.ToBinary());
public object ToObject(DbValue item, IMember member) { return(item.ToString()); }
object IDbValueConverter.ToObject(DbValue item, IMember meta) => Parse(item) !;
public object ToObject(DbValue item, IMember member) => item.ToArray <DbValue>();
public object ToObject(DbValue item, IMember member) => item.ToInt64();
public override IPAddress Parse(DbValue item) => item.Kind switch {
public object ToObject(DbValue item, IMember member) { return(item.ToBoolean()); }
public object ToObject(DbValue item, IMember member) => item.ToDouble();
public object ToObject(DbValue item, IMember member) { return(item.ToDecimal()); }
public object ToObject(DbValue item, IMember member) => item.ToBinary();
public object ToObject(DbValue item, IMember member) => JsonObject.Parse(item.ToString());
public override Uri Parse(DbValue item) => new Uri(item.ToString());
public object ToObject(DbValue item, IMember member) { var text = item.ToString(); return(JsonArray.Parse(text)); }
public override Version Parse(DbValue item) => Version.Parse(item.ToString());
public abstract T Parse(DbValue dbValue);
public override Guid Parse(DbValue item) => new Guid(item.ToBinary());
public object ToObject(DbValue item, IMember member) => DateTimeOffset.FromUnixTimeSeconds(item.ToInt64()).UtcDateTime;