public HttpResponseMessage Put(NewClassConfiguration classConfiguration) { var generator = new Generator(); var zipEntries = generator.Generate(classConfiguration).ToList(); var pushStreamContent = new PushStreamContent((stream, content, context) => { using (var zipFile = new ZipFile()) { foreach (var zipEntry in zipEntries) { var newStream = new MemoryStream(zipEntry.Stream.ToArray()); newStream.Seek(0, SeekOrigin.Begin); zipFile.AddEntry(zipEntry.FileName, newStream); } zipFile.Save(stream); stream.Close(); } }, "application/zip"); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = pushStreamContent }; //response.Headers.Add("content-disposition", $"attachment; filename={classConfiguration.Name}.zip"); return response; }
static void Main(string[] args) { var methodConfig = new MethodConfiguration("ToSimulationVariables", ReturnTypes.Normal, MethodTypes.Dependent); var classConfig = new ClassConfiguration("VariableStructureTransformer", ClassTypes.Dependent); classConfig.Methods.Add(methodConfig); //var classConfig = new ClassConfiguration("FileConfiguration", ClassTypes.Data); //classConfig.Properties.Add(new PropertyConfiguration<string>("Name")); //classConfig.Properties.Add(new PropertyConfiguration<INsCodeNamespace>("Namespace")); var generator = new Generator(); generator.Generate(classConfig); }