コード例 #1
0
ファイル: ObservationLink.cs プロジェクト: IronFox/Shard
 public static byte[] Compress(object serializable)
 {
     using (MemoryStream ms = new MemoryStream())
         using (var stream = new LZ4.LZ4Stream(Helper.Serialize(serializable), LZ4.LZ4StreamMode.Compress))
         {
             stream.CopyTo(ms);
             return(ms.ToArray());
         }
 }
コード例 #2
0
        internal static System.IO.FileInfo DecompressLZ4(System.IO.FileInfo CompressedFile)
        {
            string destinFile = CompressedFile.FullName.Replace(CompressedFile.Extension, "");

            using (var istream = new System.IO.FileStream(CompressedFile.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                using (var ostream = new System.IO.FileStream(destinFile, System.IO.FileMode.Create))
                    using (var lzStream = new LZ4.LZ4Stream(istream, LZ4.LZ4StreamMode.Decompress))
                    {
                        lzStream.CopyTo(ostream);
                    }
            return(new System.IO.FileInfo(destinFile));
        }
コード例 #3
0
        public static byte[] Compress(SDS sds)
        {
            var           serial = new Newtonsoft.Json.JsonSerializer();
            StringBuilder str    = new StringBuilder();
            TextWriter    w      = new StringWriter(str);

            foreach (var e in sds.FinalEntities)
            {
                serial.Serialize(w, e);
            }



            using (MemoryStream ms = new MemoryStream())
                using (var stream = new LZ4.LZ4Stream(Helper.Serialize(sds), LZ4.LZ4StreamMode.Compress))
                {
                    stream.CopyTo(ms);
                    return(ms.ToArray());
                }
        }