diff --git a/RogueLibsCore/Names/Localization/LanguageVersions.cs b/RogueLibsCore/Names/Localization/LanguageVersions.cs index 8a8d38b28..ce11c4913 100644 --- a/RogueLibsCore/Names/Localization/LanguageVersions.cs +++ b/RogueLibsCore/Names/Localization/LanguageVersions.cs @@ -6,7 +6,7 @@ namespace RogueLibsCore { public sealed class LanguageVersions : IXmlSerializable { - private LanguageVersions() { } + internal LanguageVersions() { } public Dictionary Entries { get; private set; } = null!; // initialized on deserialization public void WriteXml(XmlWriter xml) diff --git a/RogueLibsCore/Names/Localization/LocaleLanguage.cs b/RogueLibsCore/Names/Localization/LocaleLanguage.cs index 663e5df90..0553c6c84 100644 --- a/RogueLibsCore/Names/Localization/LocaleLanguage.cs +++ b/RogueLibsCore/Names/Localization/LocaleLanguage.cs @@ -8,7 +8,7 @@ namespace RogueLibsCore [XmlRoot("Language")] public sealed class LocaleLanguage : IXmlSerializable { - private LocaleLanguage() { } + internal LocaleLanguage() { } public string Id { get; private set; } = null!; // initialized on deserialization public int Version { get; private set; } public LanguageCode Code { get; internal set; } diff --git a/RogueLibsCore/Names/Localization/Localization.cs b/RogueLibsCore/Names/Localization/Localization.cs index 0bc9bc7ae..317d6fbd3 100644 --- a/RogueLibsCore/Names/Localization/Localization.cs +++ b/RogueLibsCore/Names/Localization/Localization.cs @@ -52,10 +52,12 @@ private static bool DownloadIndex() WebClient web = new WebClient(); web.DownloadFile(url, downloadPath); - XmlSerializer ser = new XmlSerializer(typeof(LanguageVersions)); using (FileStream stream = new FileStream(downloadPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (XmlReader reader = XmlReader.Create(stream)) - Versions = (LanguageVersions)ser.Deserialize(reader); + { + Versions = new LanguageVersions(); + Versions.ReadXml(reader); + } string lastAccessFile = Path.Combine(localePath, ".lastaccess"); File.WriteAllText(lastAccessFile, DateTime.Now.ToString(CultureInfo.InvariantCulture)); @@ -132,7 +134,6 @@ private static void UpdateLanguage(string language, string filePath, int newVers } } - private static readonly XmlSerializer languageSer = new XmlSerializer(typeof(LocaleLanguage)); private static string localePath = null!; // initialized in Init() private static void InitializeLanguages() @@ -185,7 +186,11 @@ public static void ReInitializeLanguages() { using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (XmlReader reader = XmlReader.Create(stream)) - return (LocaleLanguage)languageSer.Deserialize(reader); + { + LocaleLanguage language = new LocaleLanguage(); + language.ReadXml(reader); + return language; + } } catch {