示例#1
0
 public static byte[] DecompressLz4(this byte[] array)
 {
     using (var output = new MemoryStream())
     {
         using (var lzStream = new LZ4s.LZ4Stream(new MemoryStream(array), LZ4s.CompressionMode.Decompress, array.Length))
         {
             lzStream.CopyTo(output);
             return(output.ToArray());
         }
     }
 }
 public static byte[] DecompressLz4(this byte[] array)
 {
     using (var output = new MemoryStream())
     {
         using (var lzStream = new LZ4s.LZ4Stream(new MemoryStream(array), LZ4s.CompressionMode.Decompress, array.Length))
         {
             lzStream.CopyTo(output);
             return output.ToArray();
         }
     }
 }
示例#3
0
 public static byte[] CompressLz4(this byte[] array)
 {
     using (var output = new MemoryStream())
     {
         using (var lzStream = new LZ4s.LZ4Stream(output, LZ4s.CompressionMode.Compress, array.Length))
         {
             lzStream.Write(array, 0, array.Length);
             lzStream.Flush();
             return(output.ToArray());
         }
     }
 }
 public static byte[] CompressLz4(this byte[] array)
 {
     using (var output = new MemoryStream())
     {
         using (var lzStream = new LZ4s.LZ4Stream(output, LZ4s.CompressionMode.Compress, array.Length))
         {
             lzStream.Write(array, 0, array.Length);
             lzStream.Flush();
             return output.ToArray();
         }
     }
 }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public byte[] Serialize()
 {
     if (m_serializedBuffer == null)
     {
         using (var stream = new MemoryStream())
         {
             using (var lzStream = new LZ4s.LZ4Stream(stream, LZ4s.CompressionMode.Compress))
                 Serializer.Serialize(lzStream, this);
             m_serializedBuffer = stream.ToArray();
         }
     }
     return(m_serializedBuffer);
 }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static NetMessage Deserialize(byte[] data)
 {
     using (var stream = new LZ4s.LZ4Stream(new MemoryStream(data), LZ4s.CompressionMode.Decompress))
         return(Serializer.Deserialize <NetMessage>(stream));
 }
示例#7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static NetMessage Deserialize(byte[] data)
 {
     using (var stream = new LZ4s.LZ4Stream(new MemoryStream(data), LZ4s.CompressionMode.Decompress))            
         return Serializer.Deserialize<NetMessage>(stream);            
 }
示例#8
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public byte[] Serialize()
 {
     if (m_serializedBuffer == null)
     {
         using (var stream = new MemoryStream())
         {
             using (var lzStream = new LZ4s.LZ4Stream(stream, LZ4s.CompressionMode.Compress))
                 Serializer.Serialize(lzStream, this);
             m_serializedBuffer = stream.ToArray();
         }
     }
     return m_serializedBuffer;
 }