Beispiel #1
0
        internal static TopologyAssociation DeserializeTopologyAssociation(JsonElement element)
        {
            string          name            = default;
            string          resourceId      = default;
            AssociationType?associationType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("associationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    associationType = new AssociationType(property.Value.GetString());
                    continue;
                }
            }
            return(new TopologyAssociation(name, resourceId, associationType));
        }
Beispiel #2
0
        internal static TopologyAssociation DeserializeTopologyAssociation(JsonElement element)
        {
            Optional <string>             name            = default;
            Optional <ResourceIdentifier> resourceId      = default;
            Optional <AssociationType>    associationType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("associationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    associationType = new AssociationType(property.Value.GetString());
                    continue;
                }
            }
            return(new TopologyAssociation(name.Value, resourceId.Value, Optional.ToNullable(associationType)));
        }