1
+ using System ;
2
+ using System . Threading . Tasks ;
3
+
4
+ // ReSharper disable CheckNamespace
5
+
6
+ namespace RestSharp
7
+ {
8
+ public partial class RestClientExtensions
9
+ {
10
+ /// <summary>
11
+ /// Executes the request and callback asynchronously, authenticating if needed
12
+ /// </summary>
13
+ /// <param name="client">The IRestClient this method extends</param>
14
+ /// <param name="request">Request to be executed</param>
15
+ /// <param name="callback">Callback function to be executed upon completion</param>
16
+ [ Obsolete ( "Use ExecuteAsync that returns Task" ) ]
17
+ public static RestRequestAsyncHandle ExecuteAsync (
18
+ this IRestClient client ,
19
+ IRestRequest request ,
20
+ Action < IRestResponse > callback
21
+ )
22
+ => client . ExecuteAsync ( request , ( response , handle ) => callback ( response ) ) ;
23
+
24
+ /// <summary>
25
+ /// Executes the request and callback asynchronously, authenticating if needed
26
+ /// </summary>
27
+ /// <param name="client">The IRestClient this method extends</param>
28
+ /// <typeparam name="T">Target deserialization type</typeparam>
29
+ /// <param name="request">Request to be executed</param>
30
+ /// <param name="callback">Callback function to be executed upon completion providing access to the async handle</param>
31
+ [ Obsolete ( "Use ExecuteAsync that returns Task" ) ]
32
+ public static RestRequestAsyncHandle ExecuteAsync < T > (
33
+ this IRestClient client ,
34
+ IRestRequest request ,
35
+ Action < IRestResponse < T > > callback
36
+ ) where T : new ( )
37
+ => client . ExecuteAsync < T > ( request , ( response , asyncHandle ) => callback ( response ) ) ;
38
+
39
+ [ Obsolete ( "Use GetAsync that returns Task" ) ]
40
+ public static RestRequestAsyncHandle GetAsync < T > (
41
+ this IRestClient client ,
42
+ IRestRequest request ,
43
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
44
+ ) where T : new ( )
45
+ => client . ExecuteAsync ( request , callback , Method . GET ) ;
46
+
47
+ [ Obsolete ( "Use PostAsync that returns Task" ) ]
48
+ public static RestRequestAsyncHandle PostAsync < T > (
49
+ this IRestClient client ,
50
+ IRestRequest request ,
51
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
52
+ ) where T : new ( )
53
+ => client . ExecuteAsync ( request , callback , Method . POST ) ;
54
+
55
+ [ Obsolete ( "Use PutAsync that returns Task" ) ]
56
+ public static RestRequestAsyncHandle PutAsync < T > (
57
+ this IRestClient client ,
58
+ IRestRequest request ,
59
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
60
+ ) where T : new ( )
61
+ => client . ExecuteAsync ( request , callback , Method . PUT ) ;
62
+
63
+ [ Obsolete ( "Use HeadAsync that returns Task" ) ]
64
+ public static RestRequestAsyncHandle HeadAsync < T > (
65
+ this IRestClient client ,
66
+ IRestRequest request ,
67
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
68
+ ) where T : new ( )
69
+ => client . ExecuteAsync ( request , callback , Method . HEAD ) ;
70
+
71
+ [ Obsolete ( "Use OptionsAsync that returns Task" ) ]
72
+ public static RestRequestAsyncHandle OptionsAsync < T > (
73
+ this IRestClient client ,
74
+ IRestRequest request ,
75
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
76
+ ) where T : new ( )
77
+ => client . ExecuteAsync ( request , callback , Method . OPTIONS ) ;
78
+
79
+ [ Obsolete ( "Use PatchAsync that returns Task" ) ]
80
+ public static RestRequestAsyncHandle PatchAsync < T > (
81
+ this IRestClient client ,
82
+ IRestRequest request ,
83
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
84
+ ) where T : new ( )
85
+ => client . ExecuteAsync ( request , callback , Method . PATCH ) ;
86
+
87
+ [ Obsolete ( "Use DeleteAsync that returns Task" ) ]
88
+ public static RestRequestAsyncHandle DeleteAsync < T > (
89
+ this IRestClient client ,
90
+ IRestRequest request ,
91
+ Action < IRestResponse < T > , RestRequestAsyncHandle > callback
92
+ ) where T : new ( )
93
+ => client . ExecuteAsync ( request , callback , Method . DELETE ) ;
94
+
95
+ [ Obsolete ( "Use GetAsync that returns Task" ) ]
96
+ public static RestRequestAsyncHandle GetAsync (
97
+ this IRestClient client ,
98
+ IRestRequest request ,
99
+ Action < IRestResponse , RestRequestAsyncHandle > callback
100
+ )
101
+ => client . ExecuteAsync ( request , callback , Method . GET ) ;
102
+
103
+ [ Obsolete ( "Use PostAsync that returns Task" ) ]
104
+ public static RestRequestAsyncHandle PostAsync (
105
+ this IRestClient client ,
106
+ IRestRequest request ,
107
+ Action < IRestResponse , RestRequestAsyncHandle > callback
108
+ )
109
+ => client . ExecuteAsync ( request , callback , Method . POST ) ;
110
+
111
+ [ Obsolete ( "Use PutAsync that returns Task" ) ]
112
+ public static RestRequestAsyncHandle PutAsync (
113
+ this IRestClient client ,
114
+ IRestRequest request ,
115
+ Action < IRestResponse , RestRequestAsyncHandle > callback
116
+ )
117
+ => client . ExecuteAsync ( request , callback , Method . PUT ) ;
118
+
119
+ [ Obsolete ( "Use HeadAsync that returns Task" ) ]
120
+ public static RestRequestAsyncHandle HeadAsync (
121
+ this IRestClient client ,
122
+ IRestRequest request ,
123
+ Action < IRestResponse , RestRequestAsyncHandle > callback
124
+ )
125
+ => client . ExecuteAsync ( request , callback , Method . HEAD ) ;
126
+
127
+ [ Obsolete ( "Use OptionsAsync that returns Task" ) ]
128
+ public static RestRequestAsyncHandle OptionsAsync (
129
+ this IRestClient client ,
130
+ IRestRequest request ,
131
+ Action < IRestResponse , RestRequestAsyncHandle > callback
132
+ )
133
+ => client . ExecuteAsync ( request , callback , Method . OPTIONS ) ;
134
+
135
+ [ Obsolete ( "Use PatchAsync that returns Task" ) ]
136
+ public static RestRequestAsyncHandle PatchAsync (
137
+ this IRestClient client ,
138
+ IRestRequest request ,
139
+ Action < IRestResponse , RestRequestAsyncHandle > callback
140
+ )
141
+ => client . ExecuteAsync ( request , callback , Method . PATCH ) ;
142
+
143
+ [ Obsolete ( "Use DeleteAsync that returns Task" ) ]
144
+ public static RestRequestAsyncHandle DeleteAsync (
145
+ this IRestClient client ,
146
+ IRestRequest request ,
147
+ Action < IRestResponse , RestRequestAsyncHandle > callback
148
+ )
149
+ => client . ExecuteAsync ( request , callback , Method . DELETE ) ;
150
+
151
+ [ Obsolete ( "Use GetAsync" ) ]
152
+ public static Task < T > GetTaskAsync < T > ( this IRestClient client , IRestRequest request )
153
+ => client . ExecuteGetAsync < T > ( request ) . ContinueWith ( x => x . Result . Data ) ;
154
+
155
+ [ Obsolete ( "Use PostAsync" ) ]
156
+ public static Task < T > PostTaskAsync < T > ( this IRestClient client , IRestRequest request )
157
+ => client . ExecutePostAsync < T > ( request ) . ContinueWith ( x => x . Result . Data ) ;
158
+
159
+ [ Obsolete ( "Use PutAsync" ) ]
160
+ public static Task < T > PutTaskAsync < T > ( this IRestClient client , IRestRequest request )
161
+ => client . ExecuteAsync < T > ( request , Method . PUT ) . ContinueWith ( x => x . Result . Data ) ;
162
+
163
+ [ Obsolete ( "Use HeadAsync" ) ]
164
+ public static Task < T > HeadTaskAsync < T > ( this IRestClient client , IRestRequest request )
165
+ => client . ExecuteAsync < T > ( request , Method . HEAD ) . ContinueWith ( x => x . Result . Data ) ;
166
+
167
+ [ Obsolete ( "Use OptionsAsync" ) ]
168
+ public static Task < T > OptionsTaskAsync < T > ( this IRestClient client , IRestRequest request )
169
+ => client . ExecuteAsync < T > ( request , Method . OPTIONS ) . ContinueWith ( x => x . Result . Data ) ;
170
+
171
+ [ Obsolete ( "Use PatchAsync" ) ]
172
+ public static Task < T > PatchTaskAsync < T > ( this IRestClient client , IRestRequest request )
173
+ => client . ExecuteAsync < T > ( request , Method . PATCH ) . ContinueWith ( x => x . Result . Data ) ;
174
+
175
+ [ Obsolete ( "Use DeleteAsync" ) ]
176
+ public static Task < T > DeleteTaskAsync < T > ( this IRestClient client , IRestRequest request )
177
+ => client . ExecuteAsync < T > ( request , Method . DELETE ) . ContinueWith ( x => x . Result . Data ) ;
178
+ }
179
+ }
0 commit comments