나는 제목이 그것에 대해 이동하는 방법 윈도우 폰 8 말한다 여기에 무엇을 할 노력하고있어를 검색 할 때 데이터를 검색, JSON, IsolatedStorageSettings.ApplicationSettings에 저장 데이터를 가져 오기 :JSON이
private async void Application_Launching(object sender, LaunchingEventArgs e)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("listofCurrency", await CurrencyHelpers.getJsonCurrency());
}
CurrencyHelpers에서 :
public static KeyValuePair<double, double> getStorageCurrencyPairRates(string firstCurrency, string secondCurrency)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
double firstCurrencyRate = 1;
double secondCurrencyRate = 1;
Dictionary<string, double> currencyCollection = new Dictionary<string,double>();
//needs some code here to check if "listofCurrency" already has JSONData stored in it.
settings.TryGetValue<Dictionary<string,double>>("listofCurrency", out currencyCollection);
foreach (KeyValuePair<string, double> pair in currencyCollection)
{
if (pair.Key == firstCurrency)
{
firstCurrencyRate = pair.Value;
}
else if (pair.Key == secondCurrency)
{
secondCurrencyRate = pair.Value;
}
}
return new KeyValuePair<double, double>(firstCurrencyRate, secondCurrencyRate);
}
}
다음 MainPage로드, 나는 즉시 CurrencyHelpers에서 다른 메소드를 호출
public async static Task<Dictionary<string, double>> getJsonCurrency()
{
HttpClient client = new HttpClient();
string jsonResult = await client.GetStringAsync("http://openexchangerates.org/api/latest.json?app_id=xxxxxxx");
JSONCurrency jsonData = JsonConvert.DeserializeObject<JSONCurrency>(jsonResult);
Dictionary<string, double> currencyCollection = new Dictionary<string, double>();
currencyCollection = jsonData.Rates;
return currencyCollection;
}
아이디어는 JSON 데이터를 스토리지에 저장 한 다음 즉시 사용할 수있을 때 아이디어를 가져오고 싶습니다. 도움을 많이 받으실 수 있습니다!
(10)는 내가 동안 (사용하여 시도! settings.Contains ("listofCurrency") 그러나 다만 사이클 while 루프를 통해 스레드 결코 완료하지 않는 JSON 데이터를 얻을 수있는 기다려온 방법. –