示例#1
0
        //[Benchmark]
        public void SerializeJetpackRaw()
        {
            _writer.WriteValue(_poco.DateProp);
            _writer.WriteValue(_poco.GuidProp);
            _writer.WriteValue(_poco.IntProp);
            _writer.WriteValue(_poco.StringProp);

            _stream.Write(_writer.Buffer, 0, _writer.CurrentIndex);
            _writer.Reset();
            _stream.Seek(0, SeekOrigin.Begin);
        }
示例#2
0
        public void TestStringSplit()
        {
            var buf    = new byte[128];
            var writer = new WritableBuffer(buf, () => new byte[1024], buff => { });

            writer.WriteValue("Hello World! Hello World!");

            var newBuf = new byte[1];

            Array.Copy(buf, newBuf, 1);

            var reader = new ReadableBuffer(newBuf);
            var result = reader.ReadValue(out string value, 25);

            Assert.False(result.IsRead);

            var nextBuf = new byte[32];

            Array.Copy(buf, result.BytesRead, nextBuf, 0, 32);
            reader.Reset(nextBuf);

            result = reader.ReadValue(ref value, result.CharsRead, true);

            Assert.True(result.IsRead);
            Assert.Equal("Hello World! Hello World!", value);
        }
示例#3
0
 public void TestBool()
 {
     _wBuf.WriteValue(true);
     _rBuf.ReadValue(out bool value);
     Assert.True(value);
 }