| | 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 ConfigurationMetrics : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsCollectionDefined(Results)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("results"); |
| 0 | 22 | | writer.WriteStartObject(); |
| 0 | 23 | | foreach (var item in Results) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName(item.Key); |
| 0 | 26 | | writer.WriteNumberValue(item.Value); |
| | 27 | | } |
| 0 | 28 | | writer.WriteEndObject(); |
| | 29 | | } |
| 0 | 30 | | if (Optional.IsCollectionDefined(Queries)) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("queries"); |
| 0 | 33 | | writer.WriteStartObject(); |
| 0 | 34 | | foreach (var item in Queries) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName(item.Key); |
| 0 | 37 | | writer.WriteStringValue(item.Value); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndObject(); |
| | 40 | | } |
| 0 | 41 | | writer.WriteEndObject(); |
| 0 | 42 | | } |
| | 43 | |
|
| | 44 | | internal static ConfigurationMetrics DeserializeConfigurationMetrics(JsonElement element) |
| | 45 | | { |
| 0 | 46 | | Optional<IDictionary<string, long>> results = default; |
| 0 | 47 | | Optional<IDictionary<string, string>> queries = default; |
| 0 | 48 | | foreach (var property in element.EnumerateObject()) |
| | 49 | | { |
| 0 | 50 | | if (property.NameEquals("results")) |
| | 51 | | { |
| 0 | 52 | | Dictionary<string, long> dictionary = new Dictionary<string, long>(); |
| 0 | 53 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 54 | | { |
| 0 | 55 | | dictionary.Add(property0.Name, property0.Value.GetInt64()); |
| | 56 | | } |
| 0 | 57 | | results = dictionary; |
| 0 | 58 | | continue; |
| | 59 | | } |
| 0 | 60 | | if (property.NameEquals("queries")) |
| | 61 | | { |
| 0 | 62 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 63 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 64 | | { |
| 0 | 65 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 66 | | } |
| 0 | 67 | | queries = dictionary; |
| | 68 | | continue; |
| | 69 | | } |
| | 70 | | } |
| 0 | 71 | | return new ConfigurationMetrics(Optional.ToDictionary(results), Optional.ToDictionary(queries)); |
| | 72 | | } |
| | 73 | | } |
| | 74 | | } |