public override IEnumerable<PvcStream> Execute(IEnumerable<PvcStream> inputStreams) { var resultStreams = new List<PvcStream>(); foreach (var inputStream in inputStreams) { ZipFile zip = ZipFile.Read(inputStream); foreach (ZipEntry e in zip) { var outputStream = new ZipMemoryStream(); if (!String.IsNullOrEmpty(_password)) { e.Password = _password; } e.Extract(outputStream); var resultStream = new PvcStream(() => outputStream); resultStream.Tags.Add("unzipped"); resultStreams.Add(resultStream.As(e.FileName)); } }; return resultStreams; }
public override IEnumerable<PvcStream> Execute(IEnumerable<PvcStream> inputStreams) { //Not using .Any() to avoid multiple enumeration and to avoid converting the enumerable to list. Using good old bool set check. var hasAnyStream = false; var copyToStream = new MemoryStream(); foreach (var inputStream in inputStreams) { hasAnyStream = true; inputStream.Position = 0; inputStream.CopyTo(copyToStream); } if (!hasAnyStream) { return Enumerable.Empty<PvcStream>(); } var returnStream = new PvcStream(() => copyToStream) { Position = 0 }; return new[] { returnStream.As(_resultName) }; }