Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 public static void GetRealTimeDataAsync(GetRealTimeDataQueryBuilder url, RealTimeDataDelegate callback)
 {
     GetStationCollectionAsync(url, callback);
 }