@@ -270,10 +270,10 @@ public Uri BuildUri(IRestRequest request)
270
270
{
271
271
DoBuildUriValidations ( request ) ;
272
272
273
- var applied = ApplyUrlSegmentParamsValues ( request ) ;
273
+ var applied = GetUrlSegmentParamsValues ( request ) ;
274
274
275
- BaseUrl = applied . uri ;
276
- string resource = applied . resource ;
275
+ BaseUrl = applied . Uri ;
276
+ string resource = applied . Resource ;
277
277
278
278
string mergedUri = MergeBaseUrlAndResource ( resource ) ;
279
279
@@ -295,23 +295,23 @@ private void DoBuildUriValidations(IRestRequest request)
295
295
296
296
if ( nullValuedParams . Any ( ) )
297
297
{
298
- string names = string . Join ( ", " , nullValuedParams . Select ( name => $ "'{ name } '") . ToArray ( ) ) ;
298
+ var names = string . Join ( ", " , nullValuedParams . Select ( name => $ "'{ name } '") . ToArray ( ) ) ;
299
299
throw new ArgumentException ( $ "Cannot build uri when url segment parameter(s) { names } value is null.",
300
- " request" ) ;
300
+ nameof ( request ) ) ;
301
301
}
302
302
}
303
303
304
- private ( Uri uri , string resource ) ApplyUrlSegmentParamsValues ( IRestRequest request )
304
+ private UrlSegmentParamsValues GetUrlSegmentParamsValues ( IRestRequest request )
305
305
{
306
- string assembled = request . Resource ;
307
- bool hasResource = ! string . IsNullOrEmpty ( assembled ) ;
306
+ var assembled = request . Resource ;
307
+ var hasResource = ! string . IsNullOrEmpty ( assembled ) ;
308
308
var urlParms = request . Parameters . Where ( p => p . Type == ParameterType . UrlSegment ) ;
309
309
var builder = new UriBuilder ( BaseUrl ) ;
310
310
311
311
foreach ( var parameter in urlParms )
312
312
{
313
- string paramPlaceHolder = $ "{{{parameter.Name}}}";
314
- string paramValue = parameter . Value . ToString ( ) . UrlEncode ( ) ;
313
+ var paramPlaceHolder = $ "{{{parameter.Name}}}";
314
+ var paramValue = parameter . Value . ToString ( ) . UrlEncode ( ) ;
315
315
316
316
if ( hasResource )
317
317
{
@@ -321,12 +321,12 @@ private void DoBuildUriValidations(IRestRequest request)
321
321
builder . Path = builder . Path . UrlDecode ( ) . Replace ( paramPlaceHolder , paramValue ) ;
322
322
}
323
323
324
- return ( builder . Uri , assembled ) ;
324
+ return new UrlSegmentParamsValues ( builder . Uri , assembled ) ;
325
325
}
326
326
327
327
private string MergeBaseUrlAndResource ( string resource )
328
328
{
329
- string assembled = resource ;
329
+ var assembled = resource ;
330
330
331
331
if ( ! string . IsNullOrEmpty ( assembled ) && assembled . StartsWith ( "/" ) )
332
332
{
@@ -358,7 +358,7 @@ private string ApplyQueryStringParamsValuesToUri(string mergedUri, IRestRequest
358
358
return mergedUri ;
359
359
}
360
360
361
- string separator = mergedUri != null && mergedUri . Contains ( "?" ) ? "&" : "?" ;
361
+ var separator = mergedUri != null && mergedUri . Contains ( "?" ) ? "&" : "?" ;
362
362
363
363
return string . Concat ( mergedUri , separator , EncodeParameters ( parameters , Encoding ) ) ;
364
364
}
@@ -402,7 +402,7 @@ private IDeserializer GetHandler(string contentType)
402
402
403
403
if ( structuredSyntaxSuffixMatch . Success )
404
404
{
405
- string structuredSyntaxSuffixWildcard = "*" + structuredSyntaxSuffixMatch . Value ;
405
+ var structuredSyntaxSuffixWildcard = "*" + structuredSyntaxSuffixMatch . Value ;
406
406
if ( ContentHandlers . ContainsKey ( structuredSyntaxSuffixWildcard ) )
407
407
{
408
408
return ContentHandlers [ structuredSyntaxSuffixWildcard ] ;
@@ -428,7 +428,7 @@ private static string EncodeParameter(Parameter parameter, Encoding encoding) =>
428
428
private static readonly ParameterType [ ] MultiParameterTypes =
429
429
{ ParameterType . QueryString , ParameterType . GetOrPost } ;
430
430
431
- internal IHttp ConfigureHttp ( IRestRequest request )
431
+ private IHttp ConfigureHttp ( IRestRequest request )
432
432
{
433
433
var http = Http . Create ( ) ;
434
434
@@ -701,5 +701,17 @@ private static bool IsWildcardStructuredSuffixSyntax(string contentType)
701
701
// At this point it is probably using a wildcard structured syntax suffix, but let's confirm.
702
702
return StructuredSyntaxSuffixWildcardRegex . IsMatch ( contentType ) ;
703
703
}
704
+
705
+ private class UrlSegmentParamsValues
706
+ {
707
+ public UrlSegmentParamsValues ( Uri builderUri , string assembled )
708
+ {
709
+ Uri = builderUri ;
710
+ Resource = assembled ;
711
+ }
712
+
713
+ public Uri Uri { get ; }
714
+ public string Resource { get ; }
715
+ }
704
716
}
705
717
}
0 commit comments