| | 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 ConfigurationContent : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsCollectionDefined(DeviceContent)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("deviceContent"); |
| 0 | 22 | | writer.WriteStartObject(); |
| 0 | 23 | | foreach (var item in DeviceContent) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName(item.Key); |
| 0 | 26 | | writer.WriteObjectValue(item.Value); |
| | 27 | | } |
| 0 | 28 | | writer.WriteEndObject(); |
| | 29 | | } |
| 0 | 30 | | if (Optional.IsCollectionDefined(ModulesContent)) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("modulesContent"); |
| 0 | 33 | | writer.WriteStartObject(); |
| 0 | 34 | | foreach (var item in ModulesContent) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName(item.Key); |
| 0 | 37 | | writer.WriteObjectValue(item.Value); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndObject(); |
| | 40 | | } |
| 0 | 41 | | if (Optional.IsCollectionDefined(ModuleContent)) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("moduleContent"); |
| 0 | 44 | | writer.WriteStartObject(); |
| 0 | 45 | | foreach (var item in ModuleContent) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName(item.Key); |
| 0 | 48 | | writer.WriteObjectValue(item.Value); |
| | 49 | | } |
| 0 | 50 | | writer.WriteEndObject(); |
| | 51 | | } |
| 0 | 52 | | writer.WriteEndObject(); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | internal static ConfigurationContent DeserializeConfigurationContent(JsonElement element) |
| | 56 | | { |
| 0 | 57 | | Optional<IDictionary<string, object>> deviceContent = default; |
| 0 | 58 | | Optional<IDictionary<string, object>> modulesContent = default; |
| 0 | 59 | | Optional<IDictionary<string, object>> moduleContent = default; |
| 0 | 60 | | foreach (var property in element.EnumerateObject()) |
| | 61 | | { |
| 0 | 62 | | if (property.NameEquals("deviceContent")) |
| | 63 | | { |
| 0 | 64 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 0 | 65 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 66 | | { |
| 0 | 67 | | dictionary.Add(property0.Name, property0.Value.GetObject()); |
| | 68 | | } |
| 0 | 69 | | deviceContent = dictionary; |
| 0 | 70 | | continue; |
| | 71 | | } |
| 0 | 72 | | if (property.NameEquals("modulesContent")) |
| | 73 | | { |
| 0 | 74 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 0 | 75 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 76 | | { |
| 0 | 77 | | dictionary.Add(property0.Name, property0.Value.GetObject()); |
| | 78 | | } |
| 0 | 79 | | modulesContent = dictionary; |
| 0 | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | if (property.NameEquals("moduleContent")) |
| | 83 | | { |
| 0 | 84 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 0 | 85 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 86 | | { |
| 0 | 87 | | dictionary.Add(property0.Name, property0.Value.GetObject()); |
| | 88 | | } |
| 0 | 89 | | moduleContent = dictionary; |
| | 90 | | continue; |
| | 91 | | } |
| | 92 | | } |
| 0 | 93 | | return new ConfigurationContent(Optional.ToDictionary(deviceContent), Optional.ToDictionary(modulesContent), |
| | 94 | | } |
| | 95 | | } |
| | 96 | | } |