Ejemplo n.º 1
0
 private Task <T> DoGet <T>(string aMethod, IEnumerable <IRequestParameter> aParams) where T : IHasError
 {
     return(iExecutor.ExecuteGet <T>(aMethod, aParams).ContinueWith <T>((aTask) =>
     {
         CheckResponse <T>(aTask);
         return aTask.Result.Data;
     }, CancellationToken, TaskContinuationOptions.NotOnCanceled, TaskScheduler.Default));
 }
Ejemplo n.º 2
0
 public Task <T> GetPlain <T>(string aMethod)
 {
     return(iExecutor.ExecuteGet(aMethod, RequestParameter.EmptyList)
            .ContinueWith((aTask) =>
     {
         CheckHttpResponse(aTask);
         T deserialized = DeserializeResponse <T>(aTask.Result.Content).Result;
         return deserialized;
     }, CancellationToken, TaskContinuationOptions.NotOnFaulted, TaskScheduler.Default));
 }
Ejemplo n.º 3
0
 public Task <T> GetPlainWithError <T>(string aMethod, IList <IRequestParameter> aParams = null) where T : IHasError
 {
     if (aParams == null)
     {
         aParams = RequestParameter.EmptyList;
     }
     return(iExecutor.ExecuteGet(aMethod, aParams)
            .ContinueWith(t =>
     {
         CheckHttpResponse(t);
         T deserialized = DeserializeResponse <T>(t.Result.Content).Result;
         CheckForDeezerError <T>(deserialized);
         return deserialized;
     }, CancellationToken, TaskContinuationOptions.NotOnFaulted, TaskScheduler.Default));
 }
Ejemplo n.º 4
0
        public Task <TItem> Get <TItem>(string resource, CancellationToken cancellationToken, Func <JToken, TItem> itemFactory)
        {
            return(executor.ExecuteGet(resource, cancellationToken)
                   .ContinueWith(t =>
            {
                t.ThrowIfFaulted();

                var json = JObjectFromStream(t.Result);

                return DeserializeErrorOr <TItem>(json as JObject, itemFactory);
            }, cancellationToken, TaskContinuationOptions.NotOnCanceled | TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default));
        }