Beispiel #1
0
        public static object Decompress(byte[] data, Type type)
        {
            object obj;

            try
            {
                int    num      = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
                byte[] numArray = new byte[(int)data.Length - 4];
                Array.Copy(data, 4, numArray, 0, (int)data.Length - 4);
                byte[] numArray1 = new byte[num];
                if (ZLib.uncompress(numArray1, ref num, numArray, (int)numArray.Length) == ZLib.ZLibError.Z_OK)
                {
                    MemoryStream memoryStream = new MemoryStream(numArray1);
                    object       obj1         = (new XmlSerializer(type)).Deserialize(memoryStream);
                    memoryStream.Close();
                    obj = obj1;
                }
                else
                {
                    obj = null;
                }
            }
            catch
            {
                obj = null;
            }
            return(obj);
        }
Beispiel #2
0
        public static byte[] Decompress(byte[] data)
        {
            int destLen = (int)data[0] | (int)data[1] << 8 | (int)data[2] << 16 | (int)data[3] << 24;

            byte[] source = new byte[data.Length - 4];
            Array.Copy((Array)data, 4, (Array)source, 0, data.Length - 4);
            byte[] dest = new byte[destLen];
            if (ZLib.uncompress(dest, ref destLen, source, source.Length) != ZLib.ZLibError.Z_OK)
            {
                return((byte[])null);
            }
            return(dest);
        }
Beispiel #3
0
        public static byte[] Decompress(byte[] data)
        {
            int num = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;

            byte[] numArray = new byte[(int)data.Length - 4];
            Array.Copy(data, 4, numArray, 0, (int)data.Length - 4);
            byte[] numArray1 = new byte[num];
            if (ZLib.uncompress(numArray1, ref num, numArray, (int)numArray.Length) != ZLib.ZLibError.Z_OK)
            {
                return(null);
            }
            return(numArray1);
        }
Beispiel #4
0
 public static object Decompress(byte[] data, Type type)
 {
     try
     {
         int    destLen = (int)data[0] | (int)data[1] << 8 | (int)data[2] << 16 | (int)data[3] << 24;
         byte[] source  = new byte[data.Length - 4];
         Array.Copy((Array)data, 4, (Array)source, 0, data.Length - 4);
         byte[] numArray = new byte[destLen];
         if (ZLib.uncompress(numArray, ref destLen, source, source.Length) != ZLib.ZLibError.Z_OK)
         {
             return((object)null);
         }
         MemoryStream memoryStream = new MemoryStream(numArray);
         object       obj          = new XmlSerializer(type).Deserialize((Stream)memoryStream);
         memoryStream.Close();
         return(obj);
     }
     catch
     {
         return((object)null);
     }
 }