| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Text.Json; |
| | | 7 | | using Azure.Core; |
| | | 8 | | |
| | | 9 | | namespace Azure.DigitalTwins.Core |
| | | 10 | | { |
| | | 11 | | public partial class ModelData |
| | | 12 | | { |
| | | 13 | | // This class definition overrides deserialization implementation in order to turn the **object** type definitio |
| | | 14 | | // dictionaries, as defined in swagger comments. |
| | | 15 | | |
| | | 16 | | internal static ModelData DeserializeModelData(JsonElement element) |
| | | 17 | | { |
| | 224 | 18 | | Dictionary<string, string> displayName = default; |
| | 224 | 19 | | Dictionary<string, string> description = default; |
| | 224 | 20 | | string id = default; |
| | 224 | 21 | | DateTimeOffset? uploadTime = default; |
| | 224 | 22 | | bool? decommissioned = default; |
| | 224 | 23 | | string model = default; |
| | 2736 | 24 | | foreach (var property in element.EnumerateObject()) |
| | | 25 | | { |
| | 1144 | 26 | | if (property.NameEquals("displayName")) |
| | | 27 | | { |
| | 224 | 28 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 29 | | { |
| | | 30 | | continue; |
| | | 31 | | } |
| | | 32 | | // manual change: deserialize as a dictionary |
| | 224 | 33 | | displayName = JsonSerializer.Deserialize<Dictionary<string, string>>(property.Value.GetRawText()); |
| | 224 | 34 | | continue; |
| | | 35 | | } |
| | 920 | 36 | | if (property.NameEquals("description")) |
| | | 37 | | { |
| | 224 | 38 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 39 | | { |
| | | 40 | | continue; |
| | | 41 | | } |
| | | 42 | | // manual change: deserialize as a dictionary |
| | 224 | 43 | | description = JsonSerializer.Deserialize<Dictionary<string, string>>(property.Value.GetRawText()); |
| | 224 | 44 | | continue; |
| | | 45 | | } |
| | 696 | 46 | | if (property.NameEquals("id")) |
| | | 47 | | { |
| | 224 | 48 | | id = property.Value.GetString(); |
| | 224 | 49 | | continue; |
| | | 50 | | } |
| | 472 | 51 | | if (property.NameEquals("uploadTime")) |
| | | 52 | | { |
| | 224 | 53 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 54 | | { |
| | | 55 | | continue; |
| | | 56 | | } |
| | 224 | 57 | | uploadTime = property.Value.GetDateTimeOffset("O"); |
| | 224 | 58 | | continue; |
| | | 59 | | } |
| | 248 | 60 | | if (property.NameEquals("decommissioned")) |
| | | 61 | | { |
| | 224 | 62 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 63 | | { |
| | | 64 | | continue; |
| | | 65 | | } |
| | 224 | 66 | | decommissioned = property.Value.GetBoolean(); |
| | 224 | 67 | | continue; |
| | | 68 | | } |
| | 24 | 69 | | if (property.NameEquals("model")) |
| | | 70 | | { |
| | 24 | 71 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 72 | | { |
| | | 73 | | continue; |
| | | 74 | | } |
| | 24 | 75 | | model = property.Value.GetRawText(); |
| | | 76 | | continue; |
| | | 77 | | } |
| | | 78 | | } |
| | 224 | 79 | | return new ModelData(displayName, description, id, uploadTime, decommissioned, model); |
| | | 80 | | } |
| | | 81 | | } |
| | | 82 | | } |