public
byte[] Serialize()
{
var bf = newBinaryFormatter();
using (var ms = newMemoryStream())
{
using (var ds = newDeflateStream(ms, CompressionMode.Compress, true))
{
bf.Serialize(ds,
this);
}
return ms.ToArray();
}
}
publicstaticMiniPCMessage Deserialize(byte[] data, int offset, int count)
{
MiniPCMessage msg;
var formatter = newBinaryFormatter();
using (var ms = newMemoryStream(data, offset, count))
{
using (var ds = newDeflateStream(ms, CompressionMode.Decompress, true))
{
msg = formatter.Deserialize(ds)
asMiniPCMessage;
}
}
return msg;
}
时间: 2024-10-19 09:46:05