<commit_before>﻿using System.IO;
using System.Linq;
using SharpCompress.Common.Zip;

namespace SharpCompress.Archives.Zip
{
    public class ZipArchiveEntry : ZipEntry, IArchiveEntry
    {
        internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart part)
            : base(part)
        {
            Archive = archive;
        }

        public virtual Stream OpenEntryStream()
        {
            return Parts.Single().GetCompressedStream();
        }

        #region IArchiveEntry Members

        public IArchive Archive { get; }

        public bool IsComplete => true;

        #endregion

        public string Comment => (Parts.Single() as SeekableZipFilePart).Comment;
    }
}<commit_msg>Issue #230: preserve the compression method when getting a compressed stream for encrypted ZIP archives.<commit_after>﻿using System.IO;
using System.Linq;
using SharpCompress.Common.Zip;

namespace SharpCompress.Archives.Zip
{
    public class ZipArchiveEntry : ZipEntry, IArchiveEntry
    {
        internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart part)
            : base(part)
        {
            Archive = archive;
        }

        public virtual Stream OpenEntryStream()
        {
            var filePart = Parts.Single() as ZipFilePart;
            var compressionMethod = filePart.Header.CompressionMethod;
            var stream = filePart.GetCompressedStream();
            if (filePart.Header.CompressionMethod != compressionMethod)
            {
                filePart.Header.CompressionMethod = compressionMethod;
            }
            
            return stream; 
        }

        #region IArchiveEntry Members

        public IArchive Archive { get; }

        public bool IsComplete => true;

        #endregion

        public string Comment => (Parts.Single() as SeekableZipFilePart).Comment;
    }
}
{'fraction_non_alphanumeric': 0.07365591397849462, 'fraction_numerical': 0.0016129032258064516, 'mean_word_length': 2.2591943957968477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '972512', 'n_tokens_mistral': 515, 'n_tokens_neox': 458, 'n_words': 120}