/// <summary> /// Transform OLD Xml scenarios into the new format /// TODO: Remove this for next version /// </summary> public static void ChangeExistingScenarioFormats() { lock (BackupLock) { foreach (var file in Directory.GetFiles(ScenarioSystem.ScenariosPath).Where(f => Path.GetExtension(f) == ".xml")) { var vesselAsCfgNode = XmlConverter.ConvertToConfigNode(FileHandler.ReadFileText(file)); FileHandler.WriteToFile(file.Replace(".xml", ".txt"), vesselAsCfgNode); FileHandler.FileDelete(file); } } }
private static void SwitchToXmlAndBack(string filePath) { if (!File.Exists(filePath)) { return; } var configNode = File.ReadAllText(filePath).ToUnixString(); var xml = XmlConverter.ConvertToXml(configNode); var backToConfigNode = XmlConverter.ConvertToConfigNode(xml).ToUnixString(); Assert.IsTrue(configNode.Equals(backToConfigNode), $"Error serializing config node. File: {Path.GetFileName(filePath)}"); }
/// <summary> /// Transform OLD Xml vessels into the new format /// TODO: Remove this for next version /// </summary> public static void ChangeExistingVesselFormats() { lock (BackupLock) { foreach (var file in Directory.GetFiles(VesselsPath).Where(f => Path.GetExtension(f) == ".xml")) { if (Guid.TryParse(Path.GetFileNameWithoutExtension(file), out var vesselId)) { var vesselAsCfgNode = XmlConverter.ConvertToConfigNode(FileHandler.ReadFileText(file)); FileHandler.WriteToFile(file.Replace(".xml", ".txt"), vesselAsCfgNode); } FileHandler.FileDelete(file); } } }