예제 #1
0
        /// <summary>
        /// </summary>
        /// <param name="fname">
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        /// <typeparam name="TU">
        /// </typeparam>
        /// <returns>
        /// </returns>
        public static Dictionary <T, TU> UncompressData <T, TU>(string fname)
        {
            var    tempList   = new Dictionary <T, TU>();
            Stream fileStream = new FileStream(fname, FileMode.Open);

            ZlibStream inputStream = new ZlibStream(fileStream, CompressionMode.Decompress);

            inputStream.Seek(0, SeekOrigin.Begin);
            BinaryReader binaryReader  = new BinaryReader(inputStream);
            byte         versionlength = binaryReader.ReadByte();

            char[] version = new char[versionlength];
            version = binaryReader.ReadChars(versionlength);

            // TODO: Check version and print a warning if not same as config.xml's
            MessagePackSerializer <Dictionary <T, TU> > messagePackSerializer =
                MessagePackSerializer.Create <Dictionary <T, TU> >();

            var buffer = new byte[4];

            inputStream.Read(buffer, 0, 4);

            inputStream.Read(buffer, 0, 4);

            return(messagePackSerializer.Unpack(inputStream));
        }