-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
sdk/maps/Azure.Maps.Routing/src/Generated/Models/RouteMatrix.Serialization.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
sdk/maps/Azure.Maps.Routing/src/Models/RouteMatrix.Serialization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable disable | ||
|
||
using System.Text.Json; | ||
|
||
namespace Azure.Maps.Routing.Models | ||
{ | ||
public partial class RouteMatrix | ||
{ | ||
internal static RouteMatrix DeserializeRouteMatrix(JsonElement element) | ||
{ | ||
if (element.ValueKind == JsonValueKind.Null) | ||
{ | ||
return null; | ||
} | ||
int? statusCode = default; | ||
RouteMatrixResultResponse response = default; | ||
foreach (var property in element.EnumerateObject()) | ||
{ | ||
if (property.NameEquals("statusCode"u8)) | ||
{ | ||
if (property.Value.ValueKind == JsonValueKind.Null) | ||
{ | ||
continue; | ||
} | ||
statusCode = property.Value.GetInt32(); | ||
continue; | ||
} | ||
if (property.NameEquals("response"u8)) | ||
{ | ||
if (property.Value.ValueKind == JsonValueKind.Null) | ||
{ | ||
continue; | ||
} | ||
if (statusCode == 200) { | ||
response = RouteMatrixResultResponse.DeserializeRouteMatrixResultResponse(property.Value); | ||
} else { | ||
response = new RouteMatrixResultResponse(null); | ||
} | ||
continue; | ||
} | ||
} | ||
return new RouteMatrix(statusCode, response); | ||
} | ||
|
||
/// <summary> Deserializes the model from a raw response. </summary> | ||
/// <param name="response"> The response to deserialize the model from. </param> | ||
internal static RouteMatrix FromResponse(Response response) | ||
{ | ||
using var document = JsonDocument.Parse(response.Content); | ||
return DeserializeRouteMatrix(document.RootElement); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters