| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Network.Models |
| | 13 | | { |
| | 14 | | public partial class VirtualHubRouteV2 : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (DestinationType != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("destinationType"); |
| 0 | 22 | | writer.WriteStringValue(DestinationType); |
| | 23 | | } |
| 0 | 24 | | if (Destinations != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("destinations"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in Destinations) |
| | 29 | | { |
| 0 | 30 | | writer.WriteStringValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 0 | 34 | | if (NextHopType != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("nextHopType"); |
| 0 | 37 | | writer.WriteStringValue(NextHopType); |
| | 38 | | } |
| 0 | 39 | | if (NextHops != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("nextHops"); |
| 0 | 42 | | writer.WriteStartArray(); |
| 0 | 43 | | foreach (var item in NextHops) |
| | 44 | | { |
| 0 | 45 | | writer.WriteStringValue(item); |
| | 46 | | } |
| 0 | 47 | | writer.WriteEndArray(); |
| | 48 | | } |
| 0 | 49 | | writer.WriteEndObject(); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | internal static VirtualHubRouteV2 DeserializeVirtualHubRouteV2(JsonElement element) |
| | 53 | | { |
| 0 | 54 | | string destinationType = default; |
| 0 | 55 | | IList<string> destinations = default; |
| 0 | 56 | | string nextHopType = default; |
| 0 | 57 | | IList<string> nextHops = default; |
| 0 | 58 | | foreach (var property in element.EnumerateObject()) |
| | 59 | | { |
| 0 | 60 | | if (property.NameEquals("destinationType")) |
| | 61 | | { |
| 0 | 62 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 63 | | { |
| | 64 | | continue; |
| | 65 | | } |
| 0 | 66 | | destinationType = property.Value.GetString(); |
| 0 | 67 | | continue; |
| | 68 | | } |
| 0 | 69 | | if (property.NameEquals("destinations")) |
| | 70 | | { |
| 0 | 71 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| | 73 | | continue; |
| | 74 | | } |
| 0 | 75 | | List<string> array = new List<string>(); |
| 0 | 76 | | foreach (var item in property.Value.EnumerateArray()) |
| | 77 | | { |
| 0 | 78 | | if (item.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| 0 | 80 | | array.Add(null); |
| | 81 | | } |
| | 82 | | else |
| | 83 | | { |
| 0 | 84 | | array.Add(item.GetString()); |
| | 85 | | } |
| | 86 | | } |
| 0 | 87 | | destinations = array; |
| 0 | 88 | | continue; |
| | 89 | | } |
| 0 | 90 | | if (property.NameEquals("nextHopType")) |
| | 91 | | { |
| 0 | 92 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 93 | | { |
| | 94 | | continue; |
| | 95 | | } |
| 0 | 96 | | nextHopType = property.Value.GetString(); |
| 0 | 97 | | continue; |
| | 98 | | } |
| 0 | 99 | | if (property.NameEquals("nextHops")) |
| | 100 | | { |
| 0 | 101 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 102 | | { |
| | 103 | | continue; |
| | 104 | | } |
| 0 | 105 | | List<string> array = new List<string>(); |
| 0 | 106 | | foreach (var item in property.Value.EnumerateArray()) |
| | 107 | | { |
| 0 | 108 | | if (item.ValueKind == JsonValueKind.Null) |
| | 109 | | { |
| 0 | 110 | | array.Add(null); |
| | 111 | | } |
| | 112 | | else |
| | 113 | | { |
| 0 | 114 | | array.Add(item.GetString()); |
| | 115 | | } |
| | 116 | | } |
| 0 | 117 | | nextHops = array; |
| | 118 | | continue; |
| | 119 | | } |
| | 120 | | } |
| 0 | 121 | | return new VirtualHubRouteV2(destinationType, destinations, nextHopType, nextHops); |
| | 122 | | } |
| | 123 | | } |
| | 124 | | } |