예제 #1
0
        /// <summary>
        /// Decompresses the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>a decompressed array of <see cref="byte"/></returns>
        public static byte[] Decompress(byte[] value)
        {
            #region Access Log
#if TRACE
            {
                Handler.LogHandler.Tracking("Access Method: " + typeof(Compression).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
            }
#endif
            #endregion Access Log

            try
            {
                MemoryStream ms = new MemoryStream(value);

                Stream       stream = new SharedCache.WinServiceCommon.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(ms);
                MemoryStream result = new MemoryStream();
                byte[]       buff   = new byte[4096];
                int          read   = stream.Read(buff, 0, buff.Length);
                while (read > 0)
                {
                    result.Write(buff, 0, read);
                    read = stream.Read(buff, 0, buff.Length);
                }
                return(result.ToArray());
            }
            catch (Exception ex)
            {
                Handler.LogHandler.Force(@"A problem appears to decompress payload of message: " + ex.Message);
                return(null);
            }
        }
예제 #2
0
		/// <summary>
		/// Decompresses the specified value.
		/// </summary>
		/// <param name="value">The value.</param>
		/// <returns>a decompressed array of <see cref="byte"/></returns>
		public static byte[] Decompress(byte[] value)
		{
			#region Access Log
#if TRACE
			
			{
				Handler.LogHandler.Tracking("Access Method: " + typeof(Compression).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
			}
#endif
			#endregion Access Log

			try
			{
				MemoryStream ms = new MemoryStream(value);

				Stream stream = new SharedCache.WinServiceCommon.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(ms);
				MemoryStream result = new MemoryStream();
				byte[] buff = new byte[4096];
				int read = stream.Read(buff, 0, buff.Length);
				while (read > 0)
				{
					result.Write(buff, 0, read);
					read = stream.Read(buff, 0, buff.Length);
				}
				return result.ToArray();
			}
			catch (Exception ex)
			{
				Handler.LogHandler.Force(@"A problem appears to decompress payload of message: " + ex.Message);
				return null;
			}
		}