public List <Road> GetRoads(int CityId) { AvitoWebClient web = new AvitoWebClient(auth.CredsCont); web.Encoding = Encoding.UTF8; string json = ""; try { json = web.DownloadString(String.Format(roadsUrl, CityId)); } catch (Exception e) { throw new LocationLoadException(); } JArray arr; try { arr = JArray.Parse(json); } catch (Exception e) { return(null); } List <Road> roads = new List <Road>(); foreach (JObject x in arr) { Road r = new Road(); r.Id = Int32.Parse(x["id"].ToString()); r.Name = x["name"].ToString(); roads.Add(r); } return(roads.Count == 0 ? null : roads); }
public List<Road> GetRoads(int CityId) { AvitoWebClient web = new AvitoWebClient(auth.CredsCont); web.Encoding = Encoding.UTF8; string json = ""; try { json = web.DownloadString(String.Format(roadsUrl, CityId)); } catch (Exception e) { throw new LocationLoadException(); } JArray arr; try { arr = JArray.Parse(json); } catch (Exception e) { return null; } List<Road> roads = new List<Road>(); foreach (JObject x in arr) { Road r = new Road(); r.Id = Int32.Parse(x["id"].ToString()); r.Name = x["name"].ToString(); roads.Add(r); } return roads.Count == 0 ? null : roads; }