Example #1
0
        public static string SerializeToZipBase64 <T>(T t, CompressionType compressionProvider)
        {
            MemoryStream memStream = new MemoryStream();

            formatter.Serialize(memStream, t);
            return(Convert.ToBase64String(CompressionUtil.Compress(memStream.GetBuffer(), compressionProvider)));
        }
Example #2
0
        public static T DeSerializeFromZipBase64 <T>(string data, CompressionType compressionProvider)
        {
            MemoryStream memStream = new MemoryStream();

            byte[] datas = CompressionUtil.DeCompress(Convert.FromBase64String(data), compressionProvider);
            memStream.Write(datas, 0, datas.Length);
            memStream.Position = 0;
            return((T)formatter.Deserialize(memStream));
        }