PackSingleObject() публичный Метод

Serialize specified object to the array of Byte.
public PackSingleObject ( object objectTree ) : byte[]
objectTree object Object to be serialized.
Результат byte[]
Пример #1
0
        public void ShouldSerializeStructsWithDataContracts()
        {
            MessagePackSerializer <TestStruct> serializer = MessagePackSerializer.Get <TestStruct>();

            byte[] result = serializer.PackSingleObject(new TestStruct());

            Assert.That(result, Is.Not.Null);
        }
Пример #2
0
        public void ShouldDeserializeStructsWithDataContracts()
        {
            MessagePackSerializer <TestStruct> serializer = MessagePackSerializer.Get <TestStruct>();

            byte[] bytes = serializer.PackSingleObject(new TestStruct(123));

            TestStruct result = serializer.UnpackSingleObject(bytes);

            Assert.That(result.Field, Is.EqualTo(123));
        }