private static string WriteStringInternal(TomlTable table) { using (var ms = new MemoryStream(1024)) { var sw = new FormattingStreamWriter(ms, CultureInfo.InvariantCulture); var writer = new TomlTableWriter(sw, table.Root.Settings); writer.WriteToml(table); ms.Position = 0; StreamReader sr = new StreamReader(ms); return(sr.ReadToEnd()); } }
private static void WriteStreamInternal(TomlTable table, Stream outStream) { if (table == null) { throw new ArgumentNullException(nameof(table)); } if (outStream == null) { throw new ArgumentNullException(nameof(outStream)); } var sw = new FormattingStreamWriter(outStream, CultureInfo.InvariantCulture); var tw = new TomlTableWriter(sw, table.Root.Settings); tw.WriteToml(table); outStream.Position = 0; }
private static void WriteFileInternal(TomlTable table, string filePath, TomlSettings settings) { if (table == null) { throw new ArgumentNullException(nameof(table)); } if (filePath == null) { throw new ArgumentNullException(nameof(filePath)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } filePath.EnsureDirectoryExists(); using (var fs = new FileStream(filePath, FileMode.Create)) using (var sw = new FormattingStreamWriter(fs, CultureInfo.InvariantCulture)) { var writer = new TomlTableWriter(sw, settings); writer.WriteToml(table); } }
public override string ToString() => TomlTableWriter.WriteTomlFragment(this);