Skip to content

Commit

Permalink
Indent configs saved by the configurator app
Browse files Browse the repository at this point in the history
This makes editing configs manually via text editor easier
  • Loading branch information
Sparronator9999 committed Sep 7, 2024
1 parent 3a8e4a8 commit c8e877b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions YAMDCC.Config/YAMDCC_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

Expand Down Expand Up @@ -109,7 +110,7 @@ public sealed class YAMDCC_Config
/// </exception>
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);
Expand All @@ -124,8 +125,14 @@ public static YAMDCC_Config Load(string xmlFile)
/// <exception cref="InvalidOperationException"/>
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);
}
Expand Down

0 comments on commit c8e877b

Please sign in to comment.