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) }; }
public static string StreamToTempFile(PvcStream stream) { // be sure to start from beginning stream.Position = 0; var tmpFileName = Path.GetTempFileName(); File.WriteAllText(tmpFileName, new StreamReader(stream).ReadToEnd()); return(tmpFileName); }
private void RunAllUnitTests(PvcStream stream) { Console.WriteLine("Testing: " + stream.OriginalSourcePath); var testAssembly = Assembly.Load(File.ReadAllBytes(stream.OriginalSourcePath)); var package = new TestPackage(testAssembly.GetName().FullName); TestExecutionContext.CurrentContext.TestPackage = package; var builder = new NamespaceTreeBuilder(new TestAssembly(testAssembly, testAssembly.GetName().FullName)); var fixtures = testAssembly.GetTypes() .Where(TestFixtureBuilder.CanBuildFrom) .Select(TestFixtureBuilder.BuildFrom) .ToList(); builder.Add(fixtures); builder.RootSuite.Run(new ConsoleListener(), TestFilter.Empty); }
public static string StreamToTempFile(PvcStream stream) { // be sure to start from beginning stream.Position = 0; var tmpFileName = Path.GetTempFileName(); File.WriteAllText(tmpFileName, new StreamReader(stream).ReadToEnd()); return tmpFileName; }
private PvcStream CompressStream(PvcStream inputStream) { string html = new StreamReader(inputStream).ReadToEnd(); var compressed = compressor.compress(html); Console.WriteLine(string.Format("Minified {0} from {1} to {2} bytes", inputStream.StreamName, html.Length, compressed.Length)); return PvcUtil.StringToStream(compressed, inputStream.StreamName); }