public override void Save(string filename, OperationConfig config) { using (StreamWriter file = File.CreateText(VerifyFilename(filename))) { WriteConfig(file, config); } }
protected void WriteConfig(StreamWriter sw, OperationConfig config) { var data = Newtonsoft.Json.JsonConvert.SerializeObject(config, Newtonsoft.Json.Formatting.Indented); sw.WriteLine(data); sw.Flush(); }
public override void Save(string filename, OperationConfig config) { using (var memoryStream = new MemoryStream()) { using (var archive = new GZipStream(memoryStream, CompressionLevel.Optimal, true)) { using (var streamWriter = new StreamWriter(archive)) { base.WriteConfig(streamWriter, config); } } using (var fileStream = new FileStream(VerifyFilename(filename), FileMode.OpenOrCreate, FileAccess.Write)) { memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.CopyTo(fileStream); } } }
public override void Save(string filename, OperationConfig config) { using (var memoryStream = new MemoryStream()) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Update, true)) { var demoFile = archive.CreateEntry(filename, CompressionLevel.Optimal); using (var entryStream = demoFile.Open()) using (var streamWriter = new StreamWriter(entryStream)) { base.WriteConfig(streamWriter, config); } } using (var fileStream = new FileStream(VerifyFilename(filename), FileMode.OpenOrCreate, FileAccess.Write)) { memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.CopyTo(fileStream); } } }
public abstract void Save(string filename, OperationConfig config);