コード例 #1
0
        public async Task <DataFromJason> FetchDataAsync()
        {
            var httpClient = new HttpClient();
            var dataUri    = new Uri(DataUrl);
            var result     = new DataFromJason();

            //var responce = await httpClient.GetStringAsync(dataUri);
            //result = JsonConvert.DeserializeObject<DataFromJason>(responce);
            try
            {
                var responce = await httpClient.GetStringAsync(dataUri);

                result = JsonConvert.DeserializeObject <DataFromJason>(responce);
            }
            catch
            {
                //throw new Exception();
            }
            httpClient.Dispose();
            return(result);
        }
コード例 #2
0
        public async Task SaveDate(DataFromJason data)
        {
            var dataFile = await _localStorage.CreateFileAsync(DataFileName, CreationCollisionOption.ReplaceExisting);

            await FileIO.WriteTextAsync(dataFile, JsonConvert.SerializeObject(data));
        }