public static byte[] Compress(byte[] buffer, CompressionType?compressionType = null) { switch (compressionType) { case CompressionType.GZip: return(GZipHelper.Compress(buffer)); default: return(buffer); } }
///// <summary> ///// დეკომპრესია ბაიტების მასივის ///// </summary> ///// <param name="gzbuffer">დაკომპრესული ბაიტების მასივი (GZip)</param> ///// <returns>ჩვეულებრივი ბაიტების მასივი</returns> //private static byte[] DecompressOld(byte[] gzbuffer) //{ // if (gzbuffer == null) return null; // using (var ms = new MemoryStream()) // { // var msgLength = BitConverter.ToInt32(gzbuffer, 0); // ms.Write(gzbuffer, 4, gzbuffer.Length - 4); // var buffer = new byte[msgLength]; // ms.Position = 0; // using (var zip = new GZipStream(ms, CompressionMode.Decompress)) // { // zip.Read(buffer, 0, buffer.Length); // ms.Flush(); // return buffer; // } // } //} public static byte[] Decompress(byte[] compressedBuffer, CompressionType?compressionType = null) { switch (compressionType) { case CompressionType.GZip: return(GZipHelper.Decompress(compressedBuffer)); //case CompressType.GzipOldCore: // return DecompressOld(compressedBuffer); default: return(compressedBuffer); } }