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 string GetStringByIndex(int index) { var obj = GetValueTokenTupleByIndex(index).Item1; if (obj == null) { return(null); } var lazyStringValue = obj as LazyStringValue; if (lazyStringValue != (LazyStringValue)null) { return((string)lazyStringValue); } var lazyCompressedStringValue = obj as LazyCompressedStringValue; if (lazyCompressedStringValue != null) { return(lazyCompressedStringValue); } string result; BlittableJsonReaderObject.ConvertType(obj, out result); return(result); }
public T GetByIndex <T>(int index) { var obj = GetValueTokenTupleByIndex(index).Item1; BlittableJsonReaderObject.ConvertType(obj, out T result); return(result); }
public string GetStringByIndex(int index) { AssertContextNotDisposed(); 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); }