private static void SwitchToXmlAndBack(string filePath) { if (!File.Exists(filePath)) { return; } var configNode = File.ReadAllText(filePath); var xml = ConfigNodeXmlParser.ConvertToXml(configNode); var backToConfigNode = ConfigNodeXmlParser.ConvertToConfigNode(xml); Assert.IsTrue(configNode.Equals(backToConfigNode), $"Error serializing config node. File: {Path.GetFileName(filePath)}"); }
/// <summary> /// Returns a XML vessel in the standard KSP format /// </summary> public static string GetVesselInConfigNodeFormat(Guid vesselId) { return(CurrentVesselsInXmlFormat.TryGetValue(vesselId, out var vesselInXmlFormat) ? ConfigNodeXmlParser.ConvertToConfigNode(vesselInXmlFormat) : null); }
/// <summary> /// Returns a XML scenario in the standard KSP format /// </summary> public static string GetScenarioInConfigNodeFormat(string scenarioName) { return(CurrentScenariosInXmlFormat.TryGetValue(scenarioName, out var scenarioInXmlFormat) ? ConfigNodeXmlParser.ConvertToConfigNode(scenarioInXmlFormat) : null); }