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(); } } }
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(); } } }
/// <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); }
/// <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)); }
/// <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); }
/// <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; }