我的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中实现这一目标的最佳模式/最佳实践是什么?