示例#1
0
 public static Pathmap ImportFromFile(string file)
 {
     if (LegacyPathmap.TryLoadFile(file, out Pathmap legacyMap))
     {
         return(legacyMap);
     }
     return(Deserialize(System.IO.File.ReadAllText(file)));
 }
示例#2
0
 public static Pathmap ImportFromText(string text)
 {
     if (LegacyPathmap.TryLoad(text, out Pathmap legacyMap))
     {
         return(legacyMap);
     }
     return(Deserialize(text));
 }
示例#3
0
        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);
            }
        }