| | 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.DigitalTwins.Models |
| | 13 | | { |
| | 14 | | public partial class DigitalTwinsResource : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("location"); |
| 0 | 20 | | writer.WriteStringValue(Location); |
| 0 | 21 | | if (Optional.IsCollectionDefined(Tags)) |
| | 22 | | { |
| 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 | | } |
| | 34 | | else |
| | 35 | | { |
| 0 | 36 | | writer.WriteNull("tags"); |
| | 37 | | } |
| | 38 | | } |
| 0 | 39 | | if (Optional.IsDefined(Sku)) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("sku"); |
| 0 | 42 | | writer.WriteObjectValue(Sku); |
| | 43 | | } |
| 0 | 44 | | writer.WriteEndObject(); |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | internal static DigitalTwinsResource DeserializeDigitalTwinsResource(JsonElement element) |
| | 48 | | { |
| 0 | 49 | | Optional<string> id = default; |
| 0 | 50 | | Optional<string> name = default; |
| 0 | 51 | | Optional<string> type = default; |
| 0 | 52 | | string location = default; |
| 0 | 53 | | Optional<IDictionary<string, string>> tags = default; |
| 0 | 54 | | Optional<DigitalTwinsSkuInfo> sku = default; |
| 0 | 55 | | foreach (var property in element.EnumerateObject()) |
| | 56 | | { |
| 0 | 57 | | if (property.NameEquals("id")) |
| | 58 | | { |
| 0 | 59 | | id = property.Value.GetString(); |
| 0 | 60 | | continue; |
| | 61 | | } |
| 0 | 62 | | if (property.NameEquals("name")) |
| | 63 | | { |
| 0 | 64 | | name = property.Value.GetString(); |
| 0 | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | if (property.NameEquals("type")) |
| | 68 | | { |
| 0 | 69 | | type = property.Value.GetString(); |
| 0 | 70 | | continue; |
| | 71 | | } |
| 0 | 72 | | if (property.NameEquals("location")) |
| | 73 | | { |
| 0 | 74 | | location = property.Value.GetString(); |
| 0 | 75 | | continue; |
| | 76 | | } |
| 0 | 77 | | if (property.NameEquals("tags")) |
| | 78 | | { |
| 0 | 79 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 80 | | { |
| 0 | 81 | | tags = null; |
| 0 | 82 | | continue; |
| | 83 | | } |
| 0 | 84 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 85 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 86 | | { |
| 0 | 87 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 88 | | } |
| 0 | 89 | | tags = dictionary; |
| 0 | 90 | | continue; |
| | 91 | | } |
| 0 | 92 | | if (property.NameEquals("sku")) |
| | 93 | | { |
| 0 | 94 | | sku = DigitalTwinsSkuInfo.DeserializeDigitalTwinsSkuInfo(property.Value); |
| | 95 | | continue; |
| | 96 | | } |
| | 97 | | } |
| 0 | 98 | | return new DigitalTwinsResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), sku |
| | 99 | | } |
| | 100 | | } |
| | 101 | | } |