Пример #1
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream" /> and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (InternalDeflateStream != null)
                {
                    InternalDeflateStream.Dispose();
                    InternalDeflateStream = null;

                    if (CRCData == null)
                    {
                        CRCData = new byte[4];
                        for (int x = 0; x < 4; ++x)
                        {
                            CRCData[x] = (byte)InternalStream.ReadByte();
                        }
                    }
                }
            }
            base.Dispose(disposing);
        }
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream" /> and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (InternalDeflateStream != null)
                {
                    InternalDeflateStream.Dispose();
                    InternalDeflateStream = null;
                }
                else
                {
                    InternalStream.WriteByte(3);
                    InternalStream.WriteByte(0);
                }

                var Crc = (uint)InternalAdler32.Value;
                InternalStream.WriteByte((byte)((Crc >> 24) & 0xFF));
                InternalStream.WriteByte((byte)((Crc >> 16) & 0xFF));
                InternalStream.WriteByte((byte)((Crc >> 8) & 0xFF));
                InternalStream.WriteByte((byte)(Crc & 0xFF));
            }

            base.Dispose(disposing);
        }