Пример #1
0
        public object ToObject(DbValue item, IMember member)
        {
            if (member?.Precision == 4)
            {
                return(DateTimeOffset.FromUnixTimeMilliseconds(item.ToInt64()).UtcDateTime);
            }

            return(DateTimeOffset.FromUnixTimeSeconds(item.ToInt64()).UtcDateTime);
        }
Пример #2
0
        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()));
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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()));
            }
        }
Пример #5
0
        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");
            }
        }
Пример #6
0
        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()));
        }
Пример #7
0
        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());
            }
        }
Пример #8
0
        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());
            }
        }
Пример #9
0
        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);
        }
Пример #10
0
 public object ToObject(DbValue item, IMember member) => item.ToSet <T>();
Пример #11
0
 public object ToObject(DbValue item, IMember member) => item.ToStringSet();
Пример #12
0
        // item.ToStringSet().ToArray();

        public override string[] Parse(DbValue dbValue) => dbValue.ToArray <string>();
 public object ToObject(DbValue item, IMember member) => (AttributeCollection)item.Value;
Пример #14
0
 public override Uid Parse(DbValue item) => Uid.Deserialize(item.ToBinary());
Пример #15
0
 public object ToObject(DbValue item, IMember member)
 {
     return(item.ToString());
 }
Пример #16
0
 object IDbValueConverter.ToObject(DbValue item, IMember meta) => Parse(item) !;
Пример #17
0
 public object ToObject(DbValue item, IMember member) => item.ToArray <DbValue>();
Пример #18
0
 public object ToObject(DbValue item, IMember member)
 => item.ToInt64();
Пример #19
0
 public override IPAddress Parse(DbValue item) => item.Kind switch
 {
Пример #20
0
 public object ToObject(DbValue item, IMember member)
 {
     return(item.ToBoolean());
 }
Пример #21
0
 public object ToObject(DbValue item, IMember member) =>
 item.ToDouble();
Пример #22
0
 public object ToObject(DbValue item, IMember member)
 {
     return(item.ToDecimal());
 }
Пример #23
0
 public object ToObject(DbValue item, IMember member) => item.ToBinary();
Пример #24
0
 public object ToObject(DbValue item, IMember member) =>
 JsonObject.Parse(item.ToString());
Пример #25
0
 public override Uri Parse(DbValue item) => new Uri(item.ToString());
Пример #26
0
        public object ToObject(DbValue item, IMember member)
        {
            var text = item.ToString();

            return(JsonArray.Parse(text));
        }
Пример #27
0
 public override Version Parse(DbValue item) => Version.Parse(item.ToString());
Пример #28
0
 public abstract T Parse(DbValue dbValue);
Пример #29
0
 public override Guid Parse(DbValue item) => new Guid(item.ToBinary());
Пример #30
0
 public object ToObject(DbValue item, IMember member)
 => DateTimeOffset.FromUnixTimeSeconds(item.ToInt64()).UtcDateTime;