public static void Uncompress(LogicCompressibleString str) { if (str.IsCompressed()) { ZLibHelper.DecompressInMySQLFormat(str.RemoveCompressed(), out byte[] output); if (output != null) { str.Set(Encoding.UTF8.GetString(output), str.GetCompressed()); } } }
public static void Compress(LogicCompressibleString str) { if (!str.IsCompressed()) { int length = ZLibHelper.CompressInZLibFormat(Encoding.UTF8.GetBytes(str.Get()), out byte[] output); if (output != null) { str.Set(output); } } }
/// <summary> /// Uncompresses the <see cref="LogicCompressibleString" /> instance. /// </summary> public static void Uncompress(LogicCompressibleString str) { if (str.IsCompressed()) { int compressedLength = str.GetCompressedLength(); byte[] compressedData = str.RemoveCompressed(); int uncompressedLength = ZLibHelper.DecompressInMySQLFormat(compressedData, compressedLength, out byte[] uncompressedData); if (uncompressedLength > 0) { str.Set(LogicStringUtil.CreateString(uncompressedData, 0, uncompressedLength)); } } }
/// <summary> /// Compresses the <see cref="LogicCompressibleString" /> instance. /// </summary> public static void Compress(LogicCompressibleString str) { string strInstance = str.Get(); if (strInstance != null) { byte[] uncompressedData = LogicStringUtil.GetBytes(strInstance); int compressedLength = ZLibHelper.CompressInZLibFormat(uncompressedData, out byte[] compressedData); if (compressedLength > 0) { str.Set(compressedData, compressedLength); } } }