public static Pathmap ImportFromFile(string file) { if (LegacyPathmap.TryLoadFile(file, out Pathmap legacyMap)) { return(legacyMap); } return(Deserialize(System.IO.File.ReadAllText(file))); }
public static Pathmap ImportFromText(string text) { if (LegacyPathmap.TryLoad(text, out Pathmap legacyMap)) { return(legacyMap); } return(Deserialize(text)); }
public static bool TryLoadFile(string file, out Pathmap pathmap) { try { using (var reader = XmlReader.Create(file)) { XmlSerializer serializer = new XmlSerializer(typeof(LegacyPathmap)); LegacyPathmap legacy = (LegacyPathmap)serializer.Deserialize(reader); if ((legacy.Nodes != null && legacy.Nodes.Length > 0) || (legacy.Segments != null && legacy.Segments.Length > 0)) { pathmap = legacy.AsPathmap(); return(true); } pathmap = null; return(false); } } catch { pathmap = null; return(false); } }