Beispiel #1
0
 public IEnumerable <MapName> GetMapNames(string searchFor = null, int startPosition = 0, int?count = null)
 {
     if (!string.IsNullOrEmpty(searchFor))
     {
         searchFor.ToLower();
     }
     return(WZ.Resolve("String/Map").Children
            .SelectMany(c => c.Children)
            .Where(c =>
     {
         int mapId = 0;
         if (!int.TryParse(c.NameWithoutExtension, out mapId))
         {
             return false;
         }
         string eightDigitId = mapId.ToString("D8");
         string nineDigitId = mapId.ToString("D9");
         WZProperty eightDigits = WZ.Resolve($"Map/Map/Map{eightDigitId[0]}");
         WZProperty nineDigits = WZ.Resolve($"Map/Map/Map{nineDigitId[0]}");
         return (eightDigits?.Children?.Any(m => m.NameWithoutExtension.Equals(eightDigitId) || m.NameWithoutExtension.Equals(nineDigitId)) ?? false) || (nineDigits?.Children?.Any(m => m.NameWithoutExtension.Equals(eightDigitId) || m.NameWithoutExtension.Equals(nineDigitId)) ?? false);
     })
            .Where(c => c != null)
            .Select(c => MapName.Parse(c))
            .Where(c => string.IsNullOrEmpty(searchFor) || (!string.IsNullOrEmpty(c.Name) && c.Name.ToLower().Contains(searchFor)) || (!string.IsNullOrEmpty(c.StreetName) && c.StreetName.ToLower().Contains(searchFor)))
            .Skip(startPosition)
            .Take(count ?? int.MaxValue));
 }
Beispiel #2
0
        public MapName GetMapName(int id)
        {
            WZProperty mapName = WZ.Resolve("String/Map").Children
                                 .SelectMany(c => c.Children)
                                 .Where(c => c.NameWithoutExtension == id.ToString())
                                 .FirstOrDefault();
            MapName name = MapName.Parse(mapName);

            return(name);
        }