Ejemplo n.º 1
0
        public void TestMethod1()
        {
            Login2Gate login2Gate = new Login2Gate()
            {
                Account  = "test",
                Password = "******"
            };

            {
                var b   = MessagePack.MessagePackSerializer.Serialize(login2Gate);
                var res = MessagePack.MessagePackSerializer.Deserialize <Login2Gate>(b);
                Assert.AreEqual(login2Gate.Account, res.Account);
                Assert.AreEqual(login2Gate.Password, res.Password);
            }

            {
                using (MemoryStream ms = new MemoryStream(1024))
                {
                    Serializer.Serialize(ms, login2Gate);
                    ms.Seek(0, SeekOrigin.Begin);
                    var res = Serializer.Deserialize <Login2Gate>(ms);
                    Assert.AreEqual(login2Gate.Account, res.Account);
                    Assert.AreEqual(login2Gate.Password, res.Password);
                }

                Protobuf_netLUT.Regist(typeof(Login2Gate).Assembly);
                using (var buffer = BufferPool.Rent(1024))
                {
                    var length = MessageLUT.Serialize(login2Gate, buffer.Memory.Span);
                    var res    = MessageLUT.Deserialize(1003, buffer.Memory.Slice(0, length.length)) as Login2Gate;
                    Assert.AreEqual(login2Gate.Account, res.Account);
                    Assert.AreEqual(login2Gate.Password, res.Password);
                }
            }
        }
Ejemplo n.º 2
0
 public static Serialize MakeS2 <T>() where T : IMessage <T>
 => MessageLUT.Convert <T>(Serialize);
Ejemplo n.º 3
0
 public static Serialize MakeS2 <T>() => MessageLUT.Convert <T>(Serialize);