Skip to content

Commit de9e451

Browse files
committed
Merge branch 'restclientextensions' of https://github.com/Haacked/RestSharp into Haacked-restclientextensions
2 parents 6b1e216 + aa079d1 commit de9e451

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

RestSharp/RestClient.Async.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ namespace RestSharp
2525
{
2626
public partial class RestClient
2727
{
28-
29-
/// <summary>
30-
/// Executes the request and callback asynchronously, authenticating if needed
31-
/// </summary>
32-
/// <param name="request">Request to be executed</param>
33-
/// <param name="callback">Callback function to be executed upon completion</param>
34-
public virtual RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action<RestResponse> callback)
35-
{
36-
return ExecuteAsync(request, (response, handle) => callback(response));
37-
}
38-
3928
/// <summary>
4029
/// Executes the request and callback asynchronously, authenticating if needed
4130
/// </summary>
@@ -118,16 +107,5 @@ private void ProcessResponse(HttpResponse httpResponse, RestRequestAsyncHandle a
118107
callback(restResponse, asyncHandle);
119108
});
120109
}
121-
122-
/// <summary>
123-
/// Executes the request and callback asynchronously, authenticating if needed
124-
/// </summary>
125-
/// <typeparam name="T">Target deserialization type</typeparam>
126-
/// <param name="request">Request to be executed</param>
127-
/// <param name="callback">Callback function to be executed upon completion providing access to the async handle</param>
128-
public virtual RestRequestAsyncHandle ExecuteAsync<T>(IRestRequest request, Action<RestResponse<T>> callback) where T : new()
129-
{
130-
return ExecuteAsync<T>(request, (response, asyncHandle) => callback(response));
131-
}
132110
}
133111
}

RestSharp/RestClientExtensions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
namespace RestSharp
4+
{
5+
public static class RestClientExtensions
6+
{
7+
/// <summary>
8+
/// Executes the request and callback asynchronously, authenticating if needed
9+
/// </summary>
10+
/// <param name="client">The IRestClient this method extends</param>
11+
/// <param name="request">Request to be executed</param>
12+
/// <param name="callback">Callback function to be executed upon completion</param>
13+
public static RestRequestAsyncHandle ExecuteAsync(this IRestClient client, IRestRequest request, Action<RestResponse> callback)
14+
{
15+
return client.ExecuteAsync(request, (response, handle) => callback(response));
16+
}
17+
18+
/// <summary>
19+
/// Executes the request and callback asynchronously, authenticating if needed
20+
/// </summary>
21+
/// <param name="client">The IRestClient this method extends</param>
22+
/// <typeparam name="T">Target deserialization type</typeparam>
23+
/// <param name="request">Request to be executed</param>
24+
/// <param name="callback">Callback function to be executed upon completion providing access to the async handle</param>
25+
public static RestRequestAsyncHandle ExecuteAsync<T>(this IRestClient client, IRestRequest request, Action<RestResponse<T>> callback) where T : new()
26+
{
27+
return client.ExecuteAsync<T>(request, (response, asyncHandle) => callback(response));
28+
}
29+
}
30+
}

RestSharp/RestSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<Compile Include="Extensions\MonoHttp\Helpers.cs" />
108108
<Compile Include="Extensions\MonoHttp\HtmlEncoder.cs" />
109109
<Compile Include="Extensions\MonoHttp\HttpUtility.cs" />
110+
<Compile Include="RestClientExtensions.cs" />
110111
<Compile Include="Extensions\StringExtensions.cs" />
111112
<Compile Include="Http.Sync.cs" />
112113
<Compile Include="HttpCookie.cs" />

0 commit comments

Comments
 (0)