Ejemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (!Disposed)
            {
                if (disposing)
                {
                    _keyClockDecoder?.Dispose();
                    _clientDecoder?.Dispose();
                    _leftClockDecoder?.Dispose();
                    _rightClockDecoder?.Dispose();
                    _infoDecoder?.Dispose();
                    _stringDecoder?.Dispose();
                    _parentInfoDecoder?.Dispose();
                    _typeRefDecoder?.Dispose();
                    _lengthDecoder?.Dispose();
                }

                _keyClockDecoder   = null;
                _clientDecoder     = null;
                _leftClockDecoder  = null;
                _rightClockDecoder = null;
                _infoDecoder       = null;
                _stringDecoder     = null;
                _parentInfoDecoder = null;
                _typeRefDecoder    = null;
                _lengthDecoder     = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        public UpdateDecoderV2(Stream input, bool leaveOpen = false)
            : base(input, leaveOpen)
        {
            _keys = new List <string>();

            // Read feature flag - currently unused.
            Reader.ReadByte();

            _keyClockDecoder   = new IntDiffOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _clientDecoder     = new UintOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _leftClockDecoder  = new IntDiffOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _rightClockDecoder = new IntDiffOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _infoDecoder       = new RleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _stringDecoder     = new StringDecoder(Reader.ReadVarUint8ArrayAsStream());
            _parentInfoDecoder = new RleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _typeRefDecoder    = new UintOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
            _lengthDecoder     = new UintOptRleDecoder(Reader.ReadVarUint8ArrayAsStream());
        }
Ejemplo n.º 3
0
        public void TestStringEncoderEmptyString()
        {
            const int n       = 10;
            var       encoder = new StringEncoder();

            for (int i = 0; i < n; i++)
            {
                encoder.Write(string.Empty);
            }

            var data = encoder.ToArray();

            using var stream = new MemoryStream(data);
            var decoder = new StringDecoder(stream);

            for (int i = 0; i < n; i++)
            {
                Assert.AreEqual(string.Empty, decoder.Read());
            }
        }
Ejemplo n.º 4
0
        public void TestStringEncoder()
        {
            const int n       = 100;
            var       words   = new List <string>(n);
            var       encoder = new StringEncoder();

            for (int i = 0; i < n; i++)
            {
                var v = Guid.NewGuid().ToString();
                words.Add(v);
                encoder.Write(v);
            }

            var data = encoder.ToArray();

            using var stream = new MemoryStream(data);
            var decoder = new StringDecoder(stream);

            for (int i = 0; i < words.Count; i++)
            {
                Assert.AreEqual(words[i], decoder.Read());
            }
        }