From 27cfdce912c4751867743f7142abd784490e376d Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 25 Nov 2022 11:11:45 +0100 Subject: [PATCH] remove legacy code for XML loading --- EDPlayerJournal/HumanReadableMissionName.cs | 63 --------------------- 1 file changed, 63 deletions(-) delete mode 100644 EDPlayerJournal/HumanReadableMissionName.cs diff --git a/EDPlayerJournal/HumanReadableMissionName.cs b/EDPlayerJournal/HumanReadableMissionName.cs deleted file mode 100644 index 2ee3e10..0000000 --- a/EDPlayerJournal/HumanReadableMissionName.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml; - -namespace EDPlayerJournal; - -public class HumanReadableMissionName { - private static Dictionary? humanreadable = null; - - private static void LoadMissions() { - try { - string dir = AppDomain.CurrentDomain.BaseDirectory; - string file = Path.Combine(dir, "MissionNames.xml"); - - XmlDocument document = new XmlDocument(); - - using (FileStream stream = new FileStream(file, FileMode.Open)) { - document.Load(stream); - XmlNode? missions = document.DocumentElement; - - if (missions == null || - missions.Name != "Missions" || - missions.ChildNodes == null) { - throw new ApplicationException("Invalid XML"); - } - - humanreadable = new Dictionary(); - - foreach (XmlNode mission in missions.ChildNodes) { - if (mission.Attributes == null) { - continue; - } - - string? mission_key = mission.Attributes["Name"]?.Value; - string? mission_name = mission.InnerText; - - if (mission_key == null || mission_name == null) { - continue; - } - - humanreadable.Add(mission_key, mission_name); - } - } - } catch (Exception) { - humanreadable = null; - } - } - - public static string? MakeHumanReadableName(string name) { - LoadMissions(); - - if (humanreadable == null || name == null) { - return null; - } - - if (humanreadable.ContainsKey(name)) { - return humanreadable[name]; - } - - return null; - } -}