|  |  | 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.Iot.Hub.Service.Models | 
|  |  | 13 |  | { | 
|  |  | 14 |  |     public partial class TwinProperties : IUtf8JsonSerializable | 
|  |  | 15 |  |     { | 
|  |  | 16 |  |         void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) | 
|  |  | 17 |  |         { | 
|  | 16 | 18 |  |             writer.WriteStartObject(); | 
|  | 16 | 19 |  |             if (Optional.IsCollectionDefined(Desired)) | 
|  |  | 20 |  |             { | 
|  | 16 | 21 |  |                 writer.WritePropertyName("desired"); | 
|  | 16 | 22 |  |                 writer.WriteStartObject(); | 
|  | 128 | 23 |  |                 foreach (var item in Desired) | 
|  |  | 24 |  |                 { | 
|  | 48 | 25 |  |                     writer.WritePropertyName(item.Key); | 
|  | 48 | 26 |  |                     writer.WriteObjectValue(item.Value); | 
|  |  | 27 |  |                 } | 
|  | 16 | 28 |  |                 writer.WriteEndObject(); | 
|  |  | 29 |  |             } | 
|  | 16 | 30 |  |             if (Optional.IsCollectionDefined(Reported)) | 
|  |  | 31 |  |             { | 
|  | 16 | 32 |  |                 writer.WritePropertyName("reported"); | 
|  | 16 | 33 |  |                 writer.WriteStartObject(); | 
|  | 96 | 34 |  |                 foreach (var item in Reported) | 
|  |  | 35 |  |                 { | 
|  | 32 | 36 |  |                     writer.WritePropertyName(item.Key); | 
|  | 32 | 37 |  |                     writer.WriteObjectValue(item.Value); | 
|  |  | 38 |  |                 } | 
|  | 16 | 39 |  |                 writer.WriteEndObject(); | 
|  |  | 40 |  |             } | 
|  | 16 | 41 |  |             writer.WriteEndObject(); | 
|  | 16 | 42 |  |         } | 
|  |  | 43 |  |  | 
|  |  | 44 |  |         internal static TwinProperties DeserializeTwinProperties(JsonElement element) | 
|  |  | 45 |  |         { | 
|  | 250 | 46 |  |             Optional<IDictionary<string, object>> desired = default; | 
|  | 250 | 47 |  |             Optional<IDictionary<string, object>> reported = default; | 
|  | 1500 | 48 |  |             foreach (var property in element.EnumerateObject()) | 
|  |  | 49 |  |             { | 
|  | 500 | 50 |  |                 if (property.NameEquals("desired")) | 
|  |  | 51 |  |                 { | 
|  | 250 | 52 |  |                     Dictionary<string, object> dictionary = new Dictionary<string, object>(); | 
|  | 1628 | 53 |  |                     foreach (var property0 in property.Value.EnumerateObject()) | 
|  |  | 54 |  |                     { | 
|  | 564 | 55 |  |                         dictionary.Add(property0.Name, property0.Value.GetObject()); | 
|  |  | 56 |  |                     } | 
|  | 250 | 57 |  |                     desired = dictionary; | 
|  | 250 | 58 |  |                     continue; | 
|  |  | 59 |  |                 } | 
|  | 250 | 60 |  |                 if (property.NameEquals("reported")) | 
|  |  | 61 |  |                 { | 
|  | 250 | 62 |  |                     Dictionary<string, object> dictionary = new Dictionary<string, object>(); | 
|  | 1500 | 63 |  |                     foreach (var property0 in property.Value.EnumerateObject()) | 
|  |  | 64 |  |                     { | 
|  | 500 | 65 |  |                         dictionary.Add(property0.Name, property0.Value.GetObject()); | 
|  |  | 66 |  |                     } | 
|  | 250 | 67 |  |                     reported = dictionary; | 
|  |  | 68 |  |                     continue; | 
|  |  | 69 |  |                 } | 
|  |  | 70 |  |             } | 
|  | 250 | 71 |  |             return new TwinProperties(Optional.ToDictionary(desired), Optional.ToDictionary(reported)); | 
|  |  | 72 |  |         } | 
|  |  | 73 |  |     } | 
|  |  | 74 |  | } |