예제 #1
0
파일: Toml.cs 프로젝트: zanedp/Nett
 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());
     }
 }
예제 #2
0
파일: Toml.cs 프로젝트: zanedp/Nett
        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;
        }
예제 #3
0
파일: Toml.cs 프로젝트: zanedp/Nett
        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);
                }
        }
예제 #4
0
파일: TomlTable.cs 프로젝트: uheee/Nett
 public override string ToString()
 => TomlTableWriter.WriteTomlFragment(this);