Esempio n. 1
0
 private static IAsyncActionWithProgress <HttpProgress> loadJsonAsync <T>(IHttpAsyncOperation operation, T obj)
 {
     return(Run <HttpProgress>(async(token, progress) =>
     {
         token.Register(operation.Cancel);
         operation.Progress = (t, p) => progress.Report(p);
         var response = await operation;
         var s = await response.Content.ReadAsStringAsync();
         JsonConvert.PopulateObject(s, obj, ResponseObject.JsonSettings);
         if (obj is ResponseObject ro)
         {
             ResponseObject.Check(ro);
         }
     }));
 }
Esempio n. 2
0
 private static IAsyncOperationWithProgress <T, HttpProgress> loadJsonAsync <T>(IHttpAsyncOperation operation)
 {
     return(Run <T, HttpProgress>(async(token, progress) =>
     {
         token.Register(operation.Cancel);
         operation.Progress = (t, p) => progress.Report(p);
         var response = await operation;
         var s = await response.Content.ReadAsStringAsync();
         var r = JsonConvert.DeserializeObject <T>(s, ResponseObject.JsonSettings);
         if (r is ResponseObject ro)
         {
             ResponseObject.Check(ro);
         }
         return r;
     }));
 }