| | 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.Compute.Models |
| | 13 | | { |
| | 14 | | public partial class VirtualMachineImageResource : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("name"); |
| 0 | 20 | | writer.WriteStringValue(Name); |
| 0 | 21 | | writer.WritePropertyName("location"); |
| 0 | 22 | | writer.WriteStringValue(Location); |
| 0 | 23 | | if (Tags != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("tags"); |
| 0 | 26 | | writer.WriteStartObject(); |
| 0 | 27 | | foreach (var item in Tags) |
| | 28 | | { |
| 0 | 29 | | writer.WritePropertyName(item.Key); |
| 0 | 30 | | writer.WriteStringValue(item.Value); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndObject(); |
| | 33 | | } |
| 0 | 34 | | if (Id != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("id"); |
| 0 | 37 | | writer.WriteStringValue(Id); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndObject(); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | internal static VirtualMachineImageResource DeserializeVirtualMachineImageResource(JsonElement element) |
| | 43 | | { |
| 6352 | 44 | | string name = default; |
| 6352 | 45 | | string location = default; |
| 6352 | 46 | | IDictionary<string, string> tags = default; |
| 6352 | 47 | | string id = default; |
| 51528 | 48 | | foreach (var property in element.EnumerateObject()) |
| | 49 | | { |
| 19412 | 50 | | if (property.NameEquals("name")) |
| | 51 | | { |
| 6352 | 52 | | name = property.Value.GetString(); |
| 6352 | 53 | | continue; |
| | 54 | | } |
| 13060 | 55 | | if (property.NameEquals("location")) |
| | 56 | | { |
| 6352 | 57 | | location = property.Value.GetString(); |
| 6352 | 58 | | continue; |
| | 59 | | } |
| 6708 | 60 | | if (property.NameEquals("tags")) |
| | 61 | | { |
| 0 | 62 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 63 | | { |
| | 64 | | continue; |
| | 65 | | } |
| 0 | 66 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 67 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 68 | | { |
| 0 | 69 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| 0 | 71 | | dictionary.Add(property0.Name, null); |
| | 72 | | } |
| | 73 | | else |
| | 74 | | { |
| 0 | 75 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 76 | | } |
| | 77 | | } |
| 0 | 78 | | tags = dictionary; |
| 0 | 79 | | continue; |
| | 80 | | } |
| 6708 | 81 | | if (property.NameEquals("id")) |
| | 82 | | { |
| 6352 | 83 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 84 | | { |
| | 85 | | continue; |
| | 86 | | } |
| 6352 | 87 | | id = property.Value.GetString(); |
| | 88 | | continue; |
| | 89 | | } |
| | 90 | | } |
| 6352 | 91 | | return new VirtualMachineImageResource(id, name, location, tags); |
| | 92 | | } |
| | 93 | | } |
| | 94 | | } |