From c8e877ba274a0e5cef1581b13c877a6cab3e99df Mon Sep 17 00:00:00 2001 From: Sparronator9999 <86388887+Sparronator9999@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:50:00 +1000 Subject: [PATCH] Indent configs saved by the configurator app This makes editing configs manually via text editor easier --- YAMDCC.Config/YAMDCC_Config.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/YAMDCC.Config/YAMDCC_Config.cs b/YAMDCC.Config/YAMDCC_Config.cs index b22170c..f72b407 100644 --- a/YAMDCC.Config/YAMDCC_Config.cs +++ b/YAMDCC.Config/YAMDCC_Config.cs @@ -15,6 +15,7 @@ // YAMDCC. If not, see . using System; +using System.Text; using System.Xml; using System.Xml.Serialization; @@ -109,7 +110,7 @@ public sealed class YAMDCC_Config /// public static YAMDCC_Config Load(string xmlFile) { - XmlSerializer serialiser = new XmlSerializer(typeof(YAMDCC_Config)); + XmlSerializer serialiser = new(typeof(YAMDCC_Config)); using (XmlReader reader = XmlReader.Create(xmlFile)) { YAMDCC_Config cfg = (YAMDCC_Config)serialiser.Deserialize(reader); @@ -124,8 +125,14 @@ public static YAMDCC_Config Load(string xmlFile) /// public void Save(string xmlFile) { - XmlSerializer serializer = new XmlSerializer(typeof(YAMDCC_Config)); - using (XmlWriter writer = XmlWriter.Create(xmlFile)) + XmlSerializer serializer = new(typeof(YAMDCC_Config)); + XmlWriterSettings settings = new() + { + Indent = true, + IndentChars = "\t", + }; + + using (XmlWriter writer = XmlWriter.Create(xmlFile, settings)) { serializer.Serialize(writer, this); }