private static void AssertPackDS(Int64 value, byte expectedLength) { var actualLength = BinaryPV64Packer.GetSLength(value); Assert.Equal(expectedLength, actualLength); using (var stream = new MemoryStream()) { BinaryPV64Packer.PackS(stream, value, actualLength); stream.Seek(0, SeekOrigin.Begin); var actual = BinaryPV64Packer.UnpackS(stream, actualLength); Assert.Equal(value, actual); } }
public bool TryVisitValue(VisitArgs args, out DateTime?value) { if (args.Index > 0 && !MoveToIndex(args.Index)) { value = null; return(false); } var length = _reader.ReadByte(); if (length == BinaryZPacker.Null) { value = null; return(true); } value = new DateTime(BinaryPV64Packer.UnpackS(_stream, length), DateTimeKind.Utc).ToLocalTime(); return(true); }
public bool TryVisitValue(VisitArgs args, out TimeSpan?value) { if (args.Index > 0 && !MoveToIndex(args.Index)) { value = null; return(false); } var length = _reader.ReadByte(); if (length == BinaryZPacker.Null) { value = null; return(true); } value = new TimeSpan(BinaryPV64Packer.UnpackS(_stream, length)); return(true); }