Use always the same xml writer settings

This commit is contained in:
Flamefire committed 2013-10-18 23:40:23 +02:00
1 parent 3b82d5c13c
commit 3a8acecd5c
7 files changed
+54 -63

No files matched your search

+10 -6
View File
@@ -35,7 +35,15 @@ namespace Vocaluxe.Base
{
static class CConfig
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
/// <summary>
/// Uniform settings for writing XML files. ALWAYS use this!
/// </summary>
public static readonly XmlWriterSettings XMLSettings = new XmlWriterSettings
{
Indent = true,
Encoding = Encoding.UTF8,
ConformanceLevel = ConformanceLevel.Document
};
// Debug
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
@@ -142,10 +150,6 @@ namespace Vocaluxe.Base
public static void Init()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderSongs));
#if INSTALLER
@@ -304,7 +308,7 @@ namespace Vocaluxe.Base
XmlWriter writer = null;
try
{
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig));
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig), XMLSettings);
writer.WriteStartDocument();
writer.WriteStartElement("root");
+6
View File
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Xml;
using Vocaluxe.Base.Fonts;
using VocaluxeLib;
using VocaluxeLib.Game;
@@ -141,6 +142,11 @@ namespace Vocaluxe.Base
{
return CConfig.GetMaxNumMics();
}
public XmlWriterSettings GetXMLSettings()
{
return CConfig.XMLSettings;
}
}
class CBsettings : ISettings
+2 -7
View File
@@ -107,7 +107,6 @@ namespace Vocaluxe.Base
private const int _SkinSystemVersion = 3;
#region Vars
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static readonly List<STheme> _Themes = new List<STheme>();
public static string[] ThemeNames
{
@@ -148,10 +147,6 @@ namespace Vocaluxe.Base
#region Theme and Skin loading and writing
public static void InitTheme()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
_ListThemes();
ListSkins();
@@ -291,7 +286,7 @@ namespace Vocaluxe.Base
private static void _SaveTheme(int themeIndex)
{
#region ThemeMainFile
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), _Settings))
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), CConfig.XMLSettings))
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
@@ -333,7 +328,7 @@ namespace Vocaluxe.Base
{
for (int skinIndex = 0; skinIndex < _Skins.Count; skinIndex++)
{
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName), _Settings))
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName), CConfig.XMLSettings))
{
writer.WriteStartDocument();
writer.WriteStartElement("root");