public static void GetStationCollectionAsync(IQueryBuilder url, RealTimeDataDelegate callback) { try { if (url == null) throw new Exception("Cannot work with null-objects"); if (String.IsNullOrEmpty(url.Url)) throw new Exception("Url cannot be empty"); var client = new WebClient(); client.DownloadStringCompleted += (s, e) => { if (e.Error != null) throw e.Error; if (e.Result == null) return; var collection = JsonHelper.Deserialize< IList<Station>>(e.Result); callback(new ObservableCollection<Station>(collection)); }; client.DownloadStringAsync(new Uri(url.Url)); } catch (Exception) { throw; } }
public static void GetRealTimeDataAsync(GetRealTimeDataQueryBuilder url, RealTimeDataDelegate callback) { GetStationCollectionAsync(url, callback); }