Пример #1
0
        public void SaveVer1(IMarkerFileContentVer1 content)
        {
            _writer.BaseStream.SetLength(0);

            SaveFileHeader(content);

            CommonInfosSectionSaver.Save(_writer, content);
            MarkerInfosSectionSaver.Save(_writer, content);

            _writer.Flush();
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
                }
            }
        }
Пример #4
0
        public void SaveVer1(IMarkerFileContentVer1 header)
        {
            FileSaver fileSaver = new FileSaver(_file);

            fileSaver.SaveVer1(header);
        }
Пример #5
0
 private void SaveFileHeader(IMarkerFileContentVer1 content)
 {
     _writer.WriteLine(content.IdentificationText);
     FileSaverCommon.WriteCommentBlock(_writer, content.InlinedComments.BelowHeaderSection);
 }