/// <summary> /// Send an http request using the prebuilt <see cref="IRequestBuilder{T}" /> to build a request from the /// <typeparamref name="TParameter" /> /// </summary> /// <typeparam name="TResult">The type of the result</typeparam> /// <typeparam name="TParameter">The type of the parameter</typeparam> /// <param name="parameter">The parameter instance</param> /// <param name="progress">The progress reporter</param> /// <returns>The data returned from the server</returns> protected async Task <TResult> FetchAsync <TResult, TParameter>(TParameter parameter, Interfaces.Infrastructure.IProgress <double> progress = null) where TParameter : HttpParameter { return(await TaskBuilder.Run(async() => { try { return ResponseResolver.Resolve <TResult>(Client.GetResponse(await CreateHttpRequest(parameter), progress)); } catch (Exception e) { Error(e); return default(TResult); } }).ConfigureAwait(false)); }
/// <summary> /// Send an http request using the prebuilt <see cref="IRequestBuilder{T}" /> to build a request from the /// <typeparamref name="TParameter" /> /// </summary> /// <typeparam name="TParameter"></typeparam> /// <param name="parameter"></param> /// <param name="progress"></param> /// <returns></returns> protected async Task SendAsync <TParameter>(TParameter parameter, Interfaces.Infrastructure.IProgress <double> progress = null) where TParameter : HttpParameter { await TaskBuilder.Run(async() => Client.GetResponse(await CreateHttpRequest(parameter), progress)).ConfigureAwait(false); }
/// <summary> /// Send an http request without caring about the response /// </summary> /// <param name="request">The http request</param> /// <param name="progress">The progress reporter</param> /// <returns>The task used to wait</returns> protected async Task SendAsync(HttpRequest request, Interfaces.Infrastructure.IProgress <double> progress = null) { await TaskBuilder.Run(() => Client.GetResponse(request, progress)).ConfigureAwait(false); }
/// <summary> /// Send an http request and wait to fetch some data from the response /// </summary> /// <typeparam name="T">The type of the data</typeparam> /// <param name="request">The http request</param> /// <param name="progress">The progress handler</param> /// <returns>The data returned from the server</returns> protected async Task <T> FetchAsync <T>(HttpRequest request, Interfaces.Infrastructure.IProgress <double> progress = null) { return(await TaskBuilder.Run(() => ResponseResolver.Resolve <T>(Client.GetResponse(request, progress))).ConfigureAwait(false)); }