private void GetIconCache(string message, object callback) { var json = APCache.GetIconCacheJSON(); json = Convert.ToBase64String(CLZF2.Compress(Encoding.UTF8.GetBytes(json))); wrap = new CallbackWrapper(callback); wrap.Send(json); }
private static void SaveToLocal(string filePath, object data) { System.Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes"); using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { using (MemoryStream stream = new MemoryStream()) { BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(stream, data); byte[] bytes = new byte[stream.Length]; // Have to reset the stream Position to 0 to ensure read real bytes // stream.Position = 0; stream.Read(bytes, 0, bytes.Length); var compressBytes = CLZF2.Compress(bytes); fileStream.Write(compressBytes, 0, compressBytes.Length); } } }
private string CLZF2_Base64(string s) { return(Convert.ToBase64String(CLZF2.Compress(Encoding.UTF8.GetBytes(s)))); }