public static void Save(StreamWriter writer, IHeaderFileContentVer1 content) { writer.WriteLine(); writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.BinaryInfos) !)); FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowBinaryInfosSection); foreach (Definitions.BinaryInfosKeys key in (Definitions.BinaryInfosKeys[])Enum.GetValues(typeof(Definitions.BinaryInfosKeys))) { string?keyValue = key switch { Definitions.BinaryInfosKeys.BinaryFormat => content.BinaryFormat?.ToString(), _ => throw new NotImplementedException(), // should never happen }; if (keyValue != null) { string line = IniFormat.FormatKeyValueLine(key.ToString(), keyValue); writer.WriteLine(line); } } }
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, IHeaderFileContentVer1 content) { List <Coordinates>?channelCoordinates = content.GetChannelCoordinates(); if (channelCoordinates != null) { writer.WriteLine(); writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.Coordinates) !)); FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowCoordinatesInfosSection); for (int ch = 0; ch < channelCoordinates.Count; ++ch) { Coordinates coordinates = channelCoordinates[ch]; string keyName = Invariant($"{Definitions.KeyChPlaceholder}{ch + 1}"); string keyValue = Invariant($"{coordinates.Radius},{coordinates.Theta},{coordinates.Phi}"); string line = IniFormat.FormatKeyValueLine(keyName, keyValue); writer.WriteLine(line); } } }
public static void Save(StreamWriter writer, IHeaderFileContentVer1 content) { List <ChannelInfo>?channelInfos = content.GetChannelInfos(); if (channelInfos != null) { writer.WriteLine(); writer.WriteLine(IniFormat.FormatSectionName(Definitions.GetSectionName(Definitions.Section.ChannelInfos) !)); FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.BelowChannelInfosSection); for (int ch = 0; ch < channelInfos.Count; ++ch) { ChannelInfo channelInfo = channelInfos[ch]; string keyName = Invariant($"{Definitions.KeyChPlaceholder}{ch + 1}"); string keyValue = ConvertChannelInfoToString(channelInfo); 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 static void Save(StreamWriter writer, IHeaderFileContentVer1 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) { string?keyValue; switch (key) { case Definitions.CommonInfosKeys.Codepage: // replacing Utf8 enum with Utf-8 string keyValue = (content.CodePage == Codepage.Utf8) ? Definitions.Utf8Enum : content.CodePage?.ToString(); break; case Definitions.CommonInfosKeys.DataFile: keyValue = content.DataFile; break; case Definitions.CommonInfosKeys.MarkerFile: keyValue = content.MarkerFile; break; case Definitions.CommonInfosKeys.DataFormat: keyValue = content.DataFormat?.ToString(); break; case Definitions.CommonInfosKeys.DataType: keyValue = content.DataType?.ToString(); break; case Definitions.CommonInfosKeys.DataOrientation: if (content.DataOrientation != null) { FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.AboveDataOrientation); } keyValue = content.DataOrientation?.ToString(); break; case Definitions.CommonInfosKeys.SamplingInterval: if (content.SamplingInterval != null) { FileSaverCommon.WriteCommentBlock(writer, content.InlinedComments.AboveSamplingInterval); } keyValue = content.SamplingInterval?.ToString("R", CultureInfo.InvariantCulture); break; case Definitions.CommonInfosKeys.NumberOfChannels: keyValue = content.NumberOfChannels?.ToString(CultureInfo.InvariantCulture); break; case Definitions.CommonInfosKeys.Averaged: keyValue = content.Averaged.HasValue ? content.Averaged.Value ? YesNo.YES.ToString() : YesNo.NO.ToString() : null; break; case Definitions.CommonInfosKeys.AveragedSegments: keyValue = content.AveragedSegments?.ToString(CultureInfo.InvariantCulture); break; case Definitions.CommonInfosKeys.SegmentDataPoints: keyValue = content.SegmentDataPoints?.ToString(CultureInfo.InvariantCulture); break; case Definitions.CommonInfosKeys.SegmentationType: keyValue = content.SegmentationType?.ToString(); break; default: throw new NotImplementedException(); // should never happen } if (keyValue != null) { string line = IniFormat.FormatKeyValueLine(key.ToString(), keyValue); writer.WriteLine(line); } } }