private static bool TryGetNullableTimeSpan(BlittableJsonReaderObject json, string propertyName, out TimeSpan?timeSpan) { if (json.TryGetMember(propertyName, out var value) == false || value == null) { timeSpan = null; return(false); } if (value is LazyStringValue || value is LazyCompressedStringValue || value is string) { BlittableJsonReaderObject.ConvertType(value, out timeSpan); return(true); } if (value is long l) { timeSpan = TimeSpan.FromMilliseconds(l); return(true); } if (value is LazyNumberValue lnv) { timeSpan = TimeSpan.FromMilliseconds(lnv); return(true); } throw new FormatException($"Could not convert {value.GetType().Name} ('{value}') to {typeof(TimeSpan).Name}"); }
public T GetByIndex <T>(int index) { var obj = GetValueTokenTupleByIndex(index).Item1; T result; BlittableJsonReaderObject.ConvertType(obj, out result); return(result); }
public string GetStringByIndex(int index) { var obj = GetValueTokenTupleByIndex(index).Item1; if (obj == null) { return(null); } if (obj is LazyStringValue lazyStringValue) { return((string)lazyStringValue); } if (obj is LazyCompressedStringValue lazyCompressedStringValue) { return(lazyCompressedStringValue); } BlittableJsonReaderObject.ConvertType(obj, out string result); return(result); }