public static void AddMetadata(this ZipArchive archive, CSVMapping mapping) { var metadataEntry = archive.CreateEntry(MetadataJson); using (var stream = metadataEntry.Open()) using (StreamWriter writer = new StreamWriter(stream)) { var serializedMapping = CSVMappingHelper.Save(mapping); writer.Write(serializedMapping); } }
public static async Task <CSVMapping> RestoreMetadata(this ZipArchive archive) { var metadataEntry = archive.GetEntry(MetadataJson); using (var stream = metadataEntry.Open()) using (var reader = new StreamReader(stream)) { var serializedMapping = await reader.ReadToEndAsync(); return(CSVMappingHelper.Load(serializedMapping)); } }