MessagePack二进制序列化动态库的使用

一、MessagePack简介

MessagePack是一种高效的二进制序列化格式,它允许您像JSON一样在多个语言之间交换数据,但是他更快且更小。
它支持Python、Java、C/C++等众多语言,主要用于交换数据。--msgpack.dll类库

二、MessagePack的使用之msgpack

//MessagePack for CLI
//这是啥?
//This is MessagePack serialization/deserialization for CLI (Common Language Infrastructure) implementations such as .NET Framework, Silverlight, Mono (including Moonlight.) This library //can be used from ALL CLS compliant languages such as C#, F#, Visual Basic, Iron Python, Iron Ruby, PowerShell, C++/CLI or so.
//用法
//你可以序列化/反序列化objects用以下方法:
//1.Create serializer via MessagePackSerializer.Create generic method. This method creates dependent types serializers as well.
//2.Invoke serializer as following: ** Pack method with destination Stream and target object for serialization. ** Unpack method with source// Stream.

// Creates serializer.
var serializer = SerializationContext.Default.GetSerializer();
// Pack obj to stream.
serializer.Pack(stream, obj);
// Unpack from stream.
var unpackedObject = serializer.Unpack(stream);

' Creates serializer.
Dim serializer = SerializationContext.Default.GetSerializer(Of T)()
' Pack obj to stream.
serializer.Pack(stream, obj)
' Unpack from stream.
Dim unpackedObject = serializer.Unpack(stream)

官网:http://msgpack.org/#what-is-it



你可能感兴趣的:(类库学习,序列化)