public static string WriteToString(IniConfig iniData, IniSchemeStyle schemeStyle = null, IniWriterStyle writerStyle = null) { IniWriter.schemeStyle = schemeStyle ?? new IniSchemeStyle(); IniWriter.writerStyle = writerStyle ?? new IniWriterStyle(); TextWriter writer = new StringWriter(new StringBuilder()); bool isFirstSection = true; foreach (var section in iniData) { WriteSection(section, writer, isFirstSection); if (!isFirstSection) { isFirstSection = false; } } writer.Flush(); string iniString = writer.ToString(); writer.Close(); return(iniString); }
private static void BeginWrite() { if (schemeStyle == null) { schemeStyle = new IniSchemeStyle(); } if (writerStyle == null) { writerStyle = new IniWriterStyle(); } }
private static void EndWrite() { schemeStyle = null; writerStyle = null; }
public static string WriteToString(IniData iniData, IniSchemeStyle schemeStyle = null, IniWriterStyle writerStyle = null) { BeginWrite(); TextWriter writer = new StringWriter(new StringBuilder()); IniSection globalSection = iniData.GetSection(IniData.GLOBAL_SECTION_NAME, false); if (globalSection != null) { WriteSection(globalSection, writer); } foreach (var section in iniData) { if (section.Name != IniData.GLOBAL_SECTION_NAME) { WriteSection(section, writer); } } EndWrite(); writer.Flush(); string iniString = writer.ToString(); writer.Close(); return(iniString); }