public void SaveVer1(IMarkerFileContentVer1 content) { _writer.BaseStream.SetLength(0); SaveFileHeader(content); CommonInfosSectionSaver.Save(_writer, content); MarkerInfosSectionSaver.Save(_writer, content); _writer.Flush(); }
public static void Save(StreamWriter writer, IMarkerFileContentVer1 content) { List <MarkerInfo>?markers = content.GetMarkers(); if (markers != null) { writer.WriteLine(); writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.MarkerInfos) !)); FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowMarkerInfosSection); for (int mk = 0; mk < markers.Count; ++mk) { MarkerInfo marker = markers[mk]; string keyName = Invariant($"{Definitions.KeyMkPlaceholder}{mk + 1}"); string keyValue = ConvertMarkerInfoToString(marker); string line = IniFormat.FormatKeyValueLine(keyName, keyValue); writer.WriteLine(line); } } }
public static void Save(StreamWriter writer, IMarkerFileContentVer1 content) { writer.WriteLine(); writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.CommonInfos) !)); FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowCommonInfosSection); Definitions.CommonInfosKeys[] commonInfosKeys = (Definitions.CommonInfosKeys[])Enum.GetValues(typeof(Definitions.CommonInfosKeys)); foreach (Definitions.CommonInfosKeys key in commonInfosKeys) { var keyValue = key switch { Definitions.CommonInfosKeys.Codepage => (content.CodePage == Codepage.Utf8) ? Definitions.Utf8Enum : content.CodePage?.ToString(), // replacing Utf8 enum with Utf-8 string Definitions.CommonInfosKeys.DataFile => content.DataFile, _ => throw new NotImplementedException(), // should never happen }; if (keyValue != null) { string line = IniFormat.FormatKeyValueLine(key.ToString(), keyValue); writer.WriteLine(line); } } }
public void SaveVer1(IMarkerFileContentVer1 header) { FileSaver fileSaver = new FileSaver(_file); fileSaver.SaveVer1(header); }
private void SaveFileHeader(IMarkerFileContentVer1 content) { _writer.WriteLine(content.IdentificationText); FileSaverCommon.WriteCommentBlock(_writer, content.InlinedComments.BelowHeaderSection); }