Esempio n. 1
0
        internal static Dependency DeserializeDependency(JsonElement element)
        {
            IReadOnlyList <BasicDependency> dependsOn = default;
            string id           = default;
            string resourceType = default;
            string resourceName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("dependsOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <BasicDependency> array = new List <BasicDependency>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(BasicDependency.DeserializeBasicDependency(item));
                        }
                    }
                    dependsOn = array;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceName = property.Value.GetString();
                    continue;
                }
            }
            return(new Dependency(dependsOn, id, resourceType, resourceName));
        }
Esempio n. 2
0
        internal static Dependency DeserializeDependency(JsonElement element)
        {
            Optional <IReadOnlyList <BasicDependency> > dependsOn = default;
            Optional <string> id           = default;
            Optional <string> resourceType = default;
            Optional <string> resourceName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("dependsOn"))
                {
                    List <BasicDependency> array = new List <BasicDependency>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(BasicDependency.DeserializeBasicDependency(item));
                    }
                    dependsOn = array;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceType"))
                {
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceName"))
                {
                    resourceName = property.Value.GetString();
                    continue;
                }
            }
            return(new Dependency(Optional.ToList(dependsOn), id.Value, resourceType.Value, resourceName.Value));
        }