| | 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 TrafficSelectorPolicy : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("localAddressRanges"); |
| 0 | 20 | | writer.WriteStartArray(); |
| 0 | 21 | | foreach (var item in LocalAddressRanges) |
| | 22 | | { |
| 0 | 23 | | writer.WriteStringValue(item); |
| | 24 | | } |
| 0 | 25 | | writer.WriteEndArray(); |
| 0 | 26 | | writer.WritePropertyName("remoteAddressRanges"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in RemoteAddressRanges) |
| | 29 | | { |
| 0 | 30 | | writer.WriteStringValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| 0 | 33 | | writer.WriteEndObject(); |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | internal static TrafficSelectorPolicy DeserializeTrafficSelectorPolicy(JsonElement element) |
| | 37 | | { |
| 0 | 38 | | IList<string> localAddressRanges = default; |
| 0 | 39 | | IList<string> remoteAddressRanges = default; |
| 0 | 40 | | foreach (var property in element.EnumerateObject()) |
| | 41 | | { |
| 0 | 42 | | if (property.NameEquals("localAddressRanges")) |
| | 43 | | { |
| 0 | 44 | | List<string> array = new List<string>(); |
| 0 | 45 | | foreach (var item in property.Value.EnumerateArray()) |
| | 46 | | { |
| 0 | 47 | | if (item.ValueKind == JsonValueKind.Null) |
| | 48 | | { |
| 0 | 49 | | array.Add(null); |
| | 50 | | } |
| | 51 | | else |
| | 52 | | { |
| 0 | 53 | | array.Add(item.GetString()); |
| | 54 | | } |
| | 55 | | } |
| 0 | 56 | | localAddressRanges = array; |
| 0 | 57 | | continue; |
| | 58 | | } |
| 0 | 59 | | if (property.NameEquals("remoteAddressRanges")) |
| | 60 | | { |
| 0 | 61 | | List<string> array = new List<string>(); |
| 0 | 62 | | foreach (var item in property.Value.EnumerateArray()) |
| | 63 | | { |
| 0 | 64 | | if (item.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| 0 | 66 | | array.Add(null); |
| | 67 | | } |
| | 68 | | else |
| | 69 | | { |
| 0 | 70 | | array.Add(item.GetString()); |
| | 71 | | } |
| | 72 | | } |
| 0 | 73 | | remoteAddressRanges = array; |
| | 74 | | continue; |
| | 75 | | } |
| | 76 | | } |
| 0 | 77 | | return new TrafficSelectorPolicy(localAddressRanges, remoteAddressRanges); |
| | 78 | | } |
| | 79 | | } |
| | 80 | | } |