/// <summary> /// Load all options from the disk. /// </summary> public static void LoadRouteShieldInfo() { if (File.Exists("RouteShieldOptions.xml")) { XmlSerializer serializer = new XmlSerializer(typeof(RouteShieldObject[]), new XmlRootAttribute() { ElementName = "RouteInfoItems" }); StreamReader reader = new StreamReader("RouteShieldOptions.xml"); Dictionary <string, RouteShieldInfo> routeShieldDict = ((RouteShieldObject[])serializer.Deserialize(reader)).ToDictionary(i => i.key, i => i.value); reader.Close(); if (routeShieldDict != null) { Instance().routeShieldDictionary = routeShieldDict; LoggerUtils.Log("Loaded route shield info file."); } else { Instance().routeShieldDictionary = fallbackDict; LoggerUtils.LogError("Created route shield info is invalid!"); } } else { Instance().routeShieldDictionary = fallbackDict; LoggerUtils.LogWarning("Could not load the route shield info file!"); } }
/// <summary> /// Load all options from the disk. /// </summary> public static void LoadVmsMsgList() { if (File.Exists(FILE_NAME)) { StreamReader reader = new StreamReader(FILE_NAME); ArrayList vmsMsgStrings = JSON.JsonDecode(reader.ReadToEnd()) as ArrayList; reader.Close(); if (vmsMsgStrings != null) { Instance().msgStrings = vmsMsgStrings.Cast <string>().ToList(); LoggerUtils.Log("Loaded route VMS message file."); } else { Instance().msgStrings = fallbackMsgStrings; LoggerUtils.LogError("Created route VMS message list is invalid!"); } } else { Instance().msgStrings = fallbackMsgStrings; LoggerUtils.LogWarning("Could not load the VMS message list file!"); } }
/// <summary> /// Load all options from the disk. /// </summary> public static void LoadSettings() { if (File.Exists(FILE_NAME)) { StreamReader reader = new StreamReader(FILE_NAME); Hashtable loadedSettings = JSON.JsonDecode(reader.ReadToEnd()) as Hashtable; reader.Close(); Instance().settings = loadedSettings ?? new Hashtable { { "loadMotorwaySigns", true } }; } else { Instance().settings = new Hashtable { { "loadMotorwaySigns", true } }; LoggerUtils.LogWarning("Could not load the settings file!"); } }