Beispiel #1
0
        public void WriteVarBytes(byte[] value)
        {
            var compactSize = CompactInt.WriteCompact(_array, _cursor, (ulong)value.Length);

            Array.Copy(value, 0, _array, _cursor + compactSize, value.Length);
            _cursor += compactSize + value.Length;
        }
Beispiel #2
0
        public ulong ReadCompact()
        {
            int compactSize;
            var v = CompactInt.ReadCompact(_array, _cursor, out compactSize);

            _cursor += compactSize;
            return(v);
        }
Beispiel #3
0
        public byte[] ReadVarBytes(int maxCount)
        {
            int compactSize;
            var count = CompactInt.ReadCompact(_array, _cursor, out compactSize);

            if (count > (ulong)maxCount)
            {
                throw new Exception($"Deserialized count {count} exceeds maximum allowed value {maxCount}");
            }
            var ret = new byte[count];

            Array.Copy(_array, _cursor + compactSize, ret, 0, (int)count);
            _cursor += compactSize + (int)count;
            return(ret);
        }
Beispiel #4
0
        public void WriteCompact(ulong value)
        {
            var compactSize = CompactInt.WriteCompact(_array, _cursor, value);

            _cursor += compactSize;
        }