예제 #1
0
        private static void AssertPackDU(UInt64 value, byte expectedLength)
        {
            var actualLength = BinaryPV64Packer.GetULength(value);

            Assert.Equal(expectedLength, actualLength);
            using (var stream = new MemoryStream()) {
                BinaryPV64Packer.PackU(stream, value, actualLength);
                stream.Seek(0, SeekOrigin.Begin);
                var actual = BinaryPV64Packer.UnpackU(stream, actualLength);
                Assert.Equal(value, actual);
            }
        }
예제 #2
0
        public void VisitValue(ulong?value, VisitArgs args)
        {
            if (args.Index > 0)
            {
                BinaryZPacker.Pack(_writeBuffer, args.Index);
            }

            if (value == null)
            {
                _writeBuffer.WriteByte(BinaryZPacker.Null);
                return;
            }

            var length = BinaryPV64Packer.GetULength(value.Value);

            _writeBuffer.WriteByte(length);
            var offset = _writeBuffer.Advance(length);

            BinaryPV64Packer.PackU(_writeBuffer.Buffer, offset, value.Value, length);
        }