예제 #1
0
        protected override void Dispose(bool disposing)
        {
            if (!Disposed)
            {
                if (disposing)
                {
                    _keyMap.Clear();
                    _keyClockEncoder.Dispose();
                    _clientEncoder.Dispose();
                    _leftClockEncoder.Dispose();
                    _rightClockEncoder.Dispose();
                    _infoEncoder.Dispose();
                    _stringEncoder.Dispose();
                    _parentInfoEncoder.Dispose();
                    _typeRefEncoder.Dispose();
                    _lengthEncoder.Dispose();
                }

                _keyMap            = null;
                _keyClockEncoder   = null;
                _clientEncoder     = null;
                _leftClockEncoder  = null;
                _rightClockEncoder = null;
                _infoEncoder       = null;
                _stringEncoder     = null;
                _parentInfoEncoder = null;
                _typeRefEncoder    = null;
                _lengthEncoder     = null;
            }

            base.Dispose(disposing);
        }
예제 #2
0
        public UpdateEncoderV2()
        {
            _keyClock = 0;

            _keyMap            = new Dictionary <string, int>();
            _keyClockEncoder   = new IntDiffOptRleEncoder();
            _clientEncoder     = new UintOptRleEncoder();
            _leftClockEncoder  = new IntDiffOptRleEncoder();
            _rightClockEncoder = new IntDiffOptRleEncoder();
            _infoEncoder       = new RleEncoder();
            _stringEncoder     = new StringEncoder();
            _parentInfoEncoder = new RleEncoder();
            _typeRefEncoder    = new UintOptRleEncoder();
            _lengthEncoder     = new UintOptRleEncoder();
        }
예제 #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());
            }
        }
예제 #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());
            }
        }