如何将反序列化的JSON对象从PCL传递给ViewController?

时间:2017-02-13 15:26:54

标签: c# xamarin xamarin.ios xamarin.forms

我的PCL中有一个异步方法,它正在检索和反序列化JSON对象。一旦完成,我想将对象传递给我的ViewController,其中将用于更新UI。

var httpClient = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, testUrl);

var response = await httpClient.SendAsync(request);

Stream stream = await response.Content.ReadAsStreamAsync();

StreamReader readStream = new StreamReader(stream, Encoding.UTF8);

string dataString = readStream.ReadToEnd();

var json = JsonConvert.DeserializeObject<RootObject>(dataString);

在Xamarin中实现这一目标的最佳模式/最佳实践是什么?

0 个答案:

没有答案