internal static ApplicationStack DeserializeApplicationStack(JsonElement element)
        {
            Optional <string> name       = default;
            Optional <string> display    = default;
            Optional <string> dependency = default;
            Optional <IList <StackMajorVersion> > majorVersions = default;
            Optional <IList <ApplicationStack> >  frameworks    = default;
            Optional <IList <ApplicationStack> >  isDeprecated  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("display"))
                {
                    display = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dependency"))
                {
                    dependency = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("majorVersions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <StackMajorVersion> array = new List <StackMajorVersion>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(StackMajorVersion.DeserializeStackMajorVersion(item));
                    }
                    majorVersions = array;
                    continue;
                }
                if (property.NameEquals("frameworks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ApplicationStack> array = new List <ApplicationStack>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeApplicationStack(item));
                    }
                    frameworks = array;
                    continue;
                }
                if (property.NameEquals("isDeprecated"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ApplicationStack> array = new List <ApplicationStack>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeApplicationStack(item));
                    }
                    isDeprecated = array;
                    continue;
                }
            }
            return(new ApplicationStack(name.Value, display.Value, dependency.Value, Optional.ToList(majorVersions), Optional.ToList(frameworks), Optional.ToList(isDeprecated)));
        }
Пример #2
0
        internal static ApplicationStackResource DeserializeApplicationStackResource(JsonElement element)
        {
            Optional <string>  kind       = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;
            Optional <string>  name0      = default;
            Optional <string>  display    = default;
            Optional <string>  dependency = default;
            Optional <IList <StackMajorVersion> > majorVersions = default;
            Optional <IList <ApplicationStack> >  frameworks    = default;
            Optional <IList <ApplicationStack> >  isDeprecated  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("name"))
                        {
                            name0 = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("display"))
                        {
                            display = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("dependency"))
                        {
                            dependency = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("majorVersions"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <StackMajorVersion> array = new List <StackMajorVersion>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(StackMajorVersion.DeserializeStackMajorVersion(item));
                            }
                            majorVersions = array;
                            continue;
                        }
                        if (property0.NameEquals("frameworks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationStack> array = new List <ApplicationStack>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationStack.DeserializeApplicationStack(item));
                            }
                            frameworks = array;
                            continue;
                        }
                        if (property0.NameEquals("isDeprecated"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationStack> array = new List <ApplicationStack>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationStack.DeserializeApplicationStack(item));
                            }
                            isDeprecated = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ApplicationStackResource(id, name, type, systemData, kind.Value, name0.Value, display.Value, dependency.Value, Optional.ToList(majorVersions), Optional.ToList(frameworks), Optional.ToList(isDeprecated)));
        }