public void BuildStudentZip(Slide slide, FileInfo zipFile) { switch ((slide as ExerciseSlide)?.Exercise) { case CsProjectExerciseBlock csBlock: { var zip = new LazilyUpdatingZip( csBlock.ExerciseFolder, new[] { "checking", "bin", "obj", ".idea", ".vs" }, file => NeedExcludeFromStudentZip(csBlock, file), file => GetFileContentInStudentZip(csBlock, file), ResolveCsprojLinks(csBlock), zipFile); zip.UpdateZip(); return; } case UniversalExerciseBlock block: { using (var studentZipMemoryStream = block.GetZipMemoryStreamForStudent()) using (var fs = zipFile.OpenWrite()) studentZipMemoryStream.CopyTo(fs); return; } default: throw new InvalidOperationException($"Can't generate student zip for non-project exercise block: slide \"{slide.Title}\" ({slide.Id})"); } }
public void BuildStudentZip(Slide slide, FileInfo zipFile) { var block = (slide as ExerciseSlide)?.Exercise as ProjectExerciseBlock; if (block == null) { throw new InvalidOperationException($"Can't generate student zip for non-project exercise block: slide \"{slide.Title}\" ({slide.Id})"); } var zip = new LazilyUpdatingZip( block.ExerciseFolder, new[] { "checking", "bin", "obj" }, file => NeedExcludeFromStudentZip(block, file), file => GetFileContentInStudentZip(block, file), ResolveCsprojLinks(block), zipFile); zip.UpdateZip(); }