Esempio n. 1
0
            /// <summary>
            /// 自資料來源進行非同步資料讀取動作
            /// </summary>
            /// <returns></returns>
            public static async Task LoadAsync()
            {
                HttpClient client = new HttpClient();
                //取得結果並轉換為UTF8編碼
                //Encoding.get
                string response = Encoding.GetEncoding("Big5")
                                  .GetString(await client.GetByteArrayAsync(DataSource));

                var stationList = JArray.Parse(response)
                                  .Select(x => Station.Parse(x.Value <JObject>()))
                                  .ToList();

                ClearCache();

                foreach (var station in stationList)
                {
                    StationDictionary[station.Id] = station;
                }
            }