UnpackSingleObject() public method

Deserialize a single object from the array of Byte which contains a serialized object.

This method assumes that buffer contains single serialized object dedicatedly, so this method does not return any information related to actual consumed bytes.

This method is a counter part of PackSingleObject.

public UnpackSingleObject ( byte buffer ) : object
buffer byte An array of serialized value to be stored.
return object
Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
 /// <summary>
 ///		Directly deserialize specified MessagePack byte array as <see cref="MessagePackObject"/> tree.
 /// </summary>
 /// <param name="buffer">The stream which contains deserializing data.</param>
 /// <returns>A <see cref="MessagePackObject"/> which is root of the deserialized MessagePack object tree.</returns>
 /// <exception cref="ArgumentNullException">
 ///		<paramref name="buffer"/> is <c>null</c>.
 /// </exception>
 /// <remarks>
 ///		This method is convinient wrapper for <see cref="MessagePackSerializer.Get{T}(SerializationContext)"/> for <see cref="MessagePackObject"/>.
 ///		<note>
 ///			You cannot override this method behavior because this method uses private <see cref="SerializationContext"/> instead of default context which is able to be accessed via <see cref="SerializationContext.Default"/>.
 ///		</note>
 /// </remarks>
 public static MessagePackObject UnpackMessagePackObject(byte[] buffer)
 {
     return(_singleTonMpoDeserializer.UnpackSingleObject(buffer));
 }