Skip to content

Commit 553fd15

Browse files
committed
Removed Tuple package
1 parent d23279a commit 553fd15

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

RestSharp/RestClient.cs

+27-15
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ public Uri BuildUri(IRestRequest request)
270270
{
271271
DoBuildUriValidations(request);
272272

273-
var applied = ApplyUrlSegmentParamsValues(request);
273+
var applied = GetUrlSegmentParamsValues(request);
274274

275-
BaseUrl = applied.uri;
276-
string resource = applied.resource;
275+
BaseUrl = applied.Uri;
276+
string resource = applied.Resource;
277277

278278
string mergedUri = MergeBaseUrlAndResource(resource);
279279

@@ -295,23 +295,23 @@ private void DoBuildUriValidations(IRestRequest request)
295295

296296
if (nullValuedParams.Any())
297297
{
298-
string names = string.Join(", ", nullValuedParams.Select(name => $"'{name}'").ToArray());
298+
var names = string.Join(", ", nullValuedParams.Select(name => $"'{name}'").ToArray());
299299
throw new ArgumentException($"Cannot build uri when url segment parameter(s) {names} value is null.",
300-
"request");
300+
nameof(request));
301301
}
302302
}
303303

304-
private (Uri uri, string resource) ApplyUrlSegmentParamsValues(IRestRequest request)
304+
private UrlSegmentParamsValues GetUrlSegmentParamsValues(IRestRequest request)
305305
{
306-
string assembled = request.Resource;
307-
bool hasResource = !string.IsNullOrEmpty(assembled);
306+
var assembled = request.Resource;
307+
var hasResource = !string.IsNullOrEmpty(assembled);
308308
var urlParms = request.Parameters.Where(p => p.Type == ParameterType.UrlSegment);
309309
var builder = new UriBuilder(BaseUrl);
310310

311311
foreach (var parameter in urlParms)
312312
{
313-
string paramPlaceHolder = $"{{{parameter.Name}}}";
314-
string paramValue = parameter.Value.ToString().UrlEncode();
313+
var paramPlaceHolder = $"{{{parameter.Name}}}";
314+
var paramValue = parameter.Value.ToString().UrlEncode();
315315

316316
if (hasResource)
317317
{
@@ -321,12 +321,12 @@ private void DoBuildUriValidations(IRestRequest request)
321321
builder.Path = builder.Path.UrlDecode().Replace(paramPlaceHolder, paramValue);
322322
}
323323

324-
return (builder.Uri, assembled);
324+
return new UrlSegmentParamsValues(builder.Uri, assembled);
325325
}
326326

327327
private string MergeBaseUrlAndResource(string resource)
328328
{
329-
string assembled = resource;
329+
var assembled = resource;
330330

331331
if (!string.IsNullOrEmpty(assembled) && assembled.StartsWith("/"))
332332
{
@@ -358,7 +358,7 @@ private string ApplyQueryStringParamsValuesToUri(string mergedUri, IRestRequest
358358
return mergedUri;
359359
}
360360

361-
string separator = mergedUri != null && mergedUri.Contains("?") ? "&" : "?";
361+
var separator = mergedUri != null && mergedUri.Contains("?") ? "&" : "?";
362362

363363
return string.Concat(mergedUri, separator, EncodeParameters(parameters, Encoding));
364364
}
@@ -402,7 +402,7 @@ private IDeserializer GetHandler(string contentType)
402402

403403
if (structuredSyntaxSuffixMatch.Success)
404404
{
405-
string structuredSyntaxSuffixWildcard = "*" + structuredSyntaxSuffixMatch.Value;
405+
var structuredSyntaxSuffixWildcard = "*" + structuredSyntaxSuffixMatch.Value;
406406
if (ContentHandlers.ContainsKey(structuredSyntaxSuffixWildcard))
407407
{
408408
return ContentHandlers[structuredSyntaxSuffixWildcard];
@@ -428,7 +428,7 @@ private static string EncodeParameter(Parameter parameter, Encoding encoding) =>
428428
private static readonly ParameterType[] MultiParameterTypes =
429429
{ParameterType.QueryString, ParameterType.GetOrPost};
430430

431-
internal IHttp ConfigureHttp(IRestRequest request)
431+
private IHttp ConfigureHttp(IRestRequest request)
432432
{
433433
var http = Http.Create();
434434

@@ -701,5 +701,17 @@ private static bool IsWildcardStructuredSuffixSyntax(string contentType)
701701
// At this point it is probably using a wildcard structured syntax suffix, but let's confirm.
702702
return StructuredSyntaxSuffixWildcardRegex.IsMatch(contentType);
703703
}
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+
}
704716
}
705717
}

RestSharp/RestSharp.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<PackageReference Include="GitVersionTask" Version="4.0.0-beta*">
1919
<PrivateAssets>All</PrivateAssets>
2020
</PackageReference>
21-
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
2221
</ItemGroup>
2322
<ItemGroup>
2423
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net452'" />

0 commit comments

Comments
 (0)