Ejemplo n.º 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)
        {
            base.Dispose(disposing);

            _encryptor?.Dispose();
            _decryptor?.Dispose();
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (!disposing)
            {
                return;
            }

            _decryptor.Dispose();
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (!disposing)
            {
                return;
            }

            if (_sectorBufferCount > 0)
            {
                int towrite = _sectorBufferCount % BlockSize == 0
                    ? _sectorBufferCount
                    : (_sectorBufferCount / BlockSize + 1) * BlockSize;

                int transformedCount = _encryptor.TransformBlock(_sectorBuffer, 0, towrite, _encriptedBuffer, 0, _currentSector);
                _baseStream.Write(_encriptedBuffer, 0, towrite);
            }

            _baseStream.Dispose();
            _encryptor.Dispose();
        }