DALs.Http/RestClient.cs
/// <summary>
/// set as an asynchronous operation.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="config">The configuration.</param>
/// <param name="loader">The loader.</param>
/// <returns>Task&lt;T&gt;.</returns>
/// <exception cref="System.ArgumentException"></exception>
set as an asynchronous operation.
set as an asynchronous operation .
public virtual async Task<T> SetAsync<T>(HttpConfiguration config, Func<HttpResponseMessage, T> loader)
        {
            config.ValidateSet();
            using (HttpClient client = inits.HttpClient)
            {
                client.BaseAddress = config.Uri;
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = null;
                switch (config.RequestMethod)
                {
                    case HttpRequest.Put:
                        response = await client.PutAsJsonAsync(config.Route, config.Data);
                    break;
                    case HttpRequest.Post:
                        response = await client.PostAsJsonAsync(config.Route, config.Data);
                    break;
                }
                return loader(response);
            }
        }
public virtual async Task < T > SetAsync < T > ( HttpConfiguration config , Func < HttpResponseMessage , T > loader ) { config . ValidateSet ( ) ; using ( HttpClient client = inits . HttpClient ) { client . BaseAddress = config . Uri ; client . DefaultRequestHeaders . Accept . Clear ( ) ; client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( " " ) ) ; HttpResponseMessage response = null ; switch ( config . RequestMethod ) { case HttpRequest . Put : response = await client . PutAsJsonAsync ( config . Route , config . Data ) ; break ; case HttpRequest . Post : response = await client . PostAsJsonAsync ( config . Route , config . Data ) ; break ; } return loader ( response ) ; } }
set as an asynchronous operation.
set as an asynchronous operation .
None
None
config
HttpConfiguration
None
loader
Func<HttpResponseMessage, T>
None
typeparam
None