@@ -108,6 +108,7 @@ namespace {{packageName}}.{{apiPackage}}
108
108
/// Initializes a new instance of the <see cref =" { { classname} } " /> class.
109
109
/// </summary >
110
110
/// <returns ></returns >
111
+ [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")]
111
112
public { {classname} }() : this((string)null)
112
113
{
113
114
}
@@ -116,8 +117,9 @@ namespace {{packageName}}.{{apiPackage}}
116
117
/// Initializes a new instance of the <see cref =" { { classname} } " /> class.
117
118
/// </summary >
118
119
/// <param name =" basePath" >The target service's base path in URL format.</param >
119
- /// <exception cref =" ArgumentException" ></exception >
120
+ /// <exception cref =" ArgumentException" ></exception >
120
121
/// <returns ></returns >
122
+ [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")]
121
123
public { {classname} }(String basePath)
122
124
{
123
125
this.Configuration = {{packageName} }.Client.Configuration.MergeConfigurations(
@@ -138,6 +140,7 @@ namespace {{packageName}}.{{apiPackage}}
138
140
/// <param name =" configuration" >An instance of Configuration.</param >
139
141
/// <exception cref =" ArgumentNullException" ></exception >
140
142
/// <returns ></returns >
143
+ [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")]
141
144
public { {classname} }({ {packageName} }.Client.Configuration configuration)
142
145
{
143
146
if (configuration == null) throw new ArgumentNullException(" configuration" );
@@ -158,13 +161,14 @@ namespace {{packageName}}.{{apiPackage}}
158
161
/// Initializes a new instance of the <see cref =" { { classname} } " /> class.
159
162
/// </summary >
160
163
/// <param name =" client" >An instance of HttpClient.</param >
164
+ /// <param name =" handler" >An optional instance of HttpClientHandler that is used by HttpClient.</param >
161
165
/// <exception cref =" ArgumentNullException" ></exception >
162
166
/// <returns ></returns >
163
167
/// <remarks >
164
- /// Some configuration settings will not be applied without passing an HttpClientHandler.
168
+ /// Some configuration settings will not be applied without passing an HttpClientHandler.
165
169
/// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings.
166
170
/// </remarks >
167
- public { {classname} }(HttpClient client) : this(client, (string)null)
171
+ public { {classname} }(HttpClient client, HttpClientHandler handler = null ) : this(client, (string)null, handler )
168
172
{
169
173
}
170
174
@@ -173,22 +177,23 @@ namespace {{packageName}}.{{apiPackage}}
173
177
/// </summary >
174
178
/// <param name =" client" >An instance of HttpClient.</param >
175
179
/// <param name =" basePath" >The target service's base path in URL format.</param >
180
+ /// <param name =" handler" >An optional instance of HttpClientHandler that is used by HttpClient.</param >
176
181
/// <exception cref =" ArgumentNullException" ></exception >
177
- /// <exception cref =" ArgumentException" ></exception >
182
+ /// <exception cref =" ArgumentException" ></exception >
178
183
/// <returns ></returns >
179
- /// <remarks >
180
- /// Some configuration settings will not be applied without passing an HttpClientHandler.
184
+ /// <remarks >
185
+ /// Some configuration settings will not be applied without passing an HttpClientHandler.
181
186
/// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings.
182
187
/// </remarks >
183
- public { {classname} }(HttpClient client, String basePath)
188
+ public { {classname} }(HttpClient client, String basePath, HttpClientHandler handler = null )
184
189
{
185
190
if (client == null) throw new ArgumentNullException(" client" );
186
191
187
192
this.Configuration = {{packageName} }.Client.Configuration.MergeConfigurations(
188
193
{ {packageName} }.Client.GlobalConfiguration.Instance,
189
194
new { {packageName} }.Client.Configuration { BasePath = basePath }
190
195
);
191
- this.ApiClient = new { {packageName} }.Client.ApiClient(client, this.Configuration.BasePath);
196
+ this.ApiClient = new { {packageName} }.Client.ApiClient(client, this.Configuration.BasePath, handler );
192
197
this.Client = this.ApiClient;
193
198
{ {#supportsAsync} }
194
199
this.AsynchronousClient = this.ApiClient;
@@ -201,85 +206,23 @@ namespace {{packageName}}.{{apiPackage}}
201
206
/// </summary >
202
207
/// <param name =" client" >An instance of HttpClient.</param >
203
208
/// <param name =" configuration" >An instance of Configuration.</param >
209
+ /// <param name =" handler" >An optional instance of HttpClientHandler that is used by HttpClient.</param >
204
210
/// <exception cref =" ArgumentNullException" ></exception >
205
211
/// <returns ></returns >
206
212
/// <remarks >
207
- /// Some configuration settings will not be applied without passing an HttpClientHandler.
213
+ /// Some configuration settings will not be applied without passing an HttpClientHandler.
208
214
/// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings.
209
215
/// </remarks >
210
- public { {classname} }(HttpClient client, { {packageName} }.Client.Configuration configuration)
216
+ public { {classname} }(HttpClient client, { {packageName} }.Client.Configuration configuration, HttpClientHandler handler = null )
211
217
{
212
218
if (configuration == null) throw new ArgumentNullException(" configuration" );
213
- if (client == null) throw new ArgumentNullException(" client" );
214
-
215
- this.Configuration = {{packageName} }.Client.Configuration.MergeConfigurations(
216
- { {packageName} }.Client.GlobalConfiguration.Instance,
217
- configuration
218
- );
219
- this.ApiClient = new { {packageName} }.Client.ApiClient(client, this.Configuration.BasePath);
220
- this.Client = this.ApiClient;
221
- { {#supportsAsync} }
222
- this.AsynchronousClient = this.ApiClient;
223
- { {/supportsAsync} }
224
- ExceptionFactory = { {packageName} }.Client.Configuration.DefaultExceptionFactory;
225
- }
226
-
227
- /// <summary >
228
- /// Initializes a new instance of the <see cref =" { { classname} } " /> class.
229
- /// </summary >
230
- /// <param name =" client" >An instance of HttpClient.</param >
231
- /// <param name =" handler" >An instance of HttpClientHandler that is used by HttpClient.</param >
232
- /// <exception cref =" ArgumentNullException" ></exception >
233
- /// <returns ></returns >
234
- public { {classname} }(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null)
235
- {
236
- }
237
-
238
- /// <summary >
239
- /// Initializes a new instance of the <see cref =" { { classname} } " /> class.
240
- /// </summary >
241
- /// <param name =" client" >An instance of HttpClient.</param >
242
- /// <param name =" handler" >An instance of HttpClientHandler that is used by HttpClient.</param >
243
- /// <param name =" basePath" >The target service's base path in URL format.</param >
244
- /// <exception cref =" ArgumentNullException" ></exception >
245
- /// <exception cref =" ArgumentException" ></exception >
246
- /// <returns ></returns >
247
- public { {classname} }(HttpClient client, HttpClientHandler handler, String basePath)
248
- {
249
219
if (client == null) throw new ArgumentNullException(" client" );
250
- if (handler == null) throw new ArgumentNullException(" handler" );
251
-
252
- this.Configuration = {{packageName} }.Client.Configuration.MergeConfigurations(
253
- { {packageName} }.Client.GlobalConfiguration.Instance,
254
- new { {packageName} }.Client.Configuration { BasePath = basePath }
255
- );
256
- this.ApiClient = new { {packageName} }.Client.ApiClient(client, handler, this.Configuration.BasePath);
257
- this.Client = this.ApiClient;
258
- { {#supportsAsync} }
259
- this.AsynchronousClient = this.ApiClient;
260
- { {/supportsAsync} }
261
- this.ExceptionFactory = { {packageName} }.Client.Configuration.DefaultExceptionFactory;
262
- }
263
-
264
- /// <summary >
265
- /// Initializes a new instance of the <see cref =" { { classname} } " /> class using Configuration object.
266
- /// </summary >
267
- /// <param name =" client" >An instance of HttpClient.</param >
268
- /// <param name =" handler" >An instance of HttpClientHandler that is used by HttpClient.</param >
269
- /// <param name =" configuration" >An instance of Configuration.</param >
270
- /// <exception cref =" ArgumentNullException" ></exception >
271
- /// <returns ></returns >
272
- public { {classname} }(HttpClient client, HttpClientHandler handler, { {packageName} }.Client.Configuration configuration)
273
- {
274
- if (configuration == null) throw new ArgumentNullException(" configuration" );
275
- if (client == null) throw new ArgumentNullException(" client" );
276
- if (handler == null) throw new ArgumentNullException(" handler" );
277
220
278
221
this.Configuration = {{packageName} }.Client.Configuration.MergeConfigurations(
279
222
{ {packageName} }.Client.GlobalConfiguration.Instance,
280
223
configuration
281
224
);
282
- this.ApiClient = new { {packageName} }.Client.ApiClient(client, handler, this.Configuration.BasePath);
225
+ this.ApiClient = new { {packageName} }.Client.ApiClient(client, this.Configuration.BasePath, handler );
283
226
this.Client = this.ApiClient;
284
227
{ {#supportsAsync} }
285
228
this.AsynchronousClient = this.ApiClient;
0 commit comments