internal static ResourceSkuZoneDetails DeserializeResourceSkuZoneDetails(JsonElement element)
        {
            Optional <IReadOnlyList <string> >        name         = default;
            Optional <IReadOnlyList <SKUCapability> > capabilities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    name = array;
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SKUCapability> array = new List <SKUCapability>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SKUCapability.DeserializeSKUCapability(item));
                    }
                    capabilities = array;
                    continue;
                }
            }
            return(new ResourceSkuZoneDetails(Optional.ToList(name), Optional.ToList(capabilities)));
        }
示例#2
0
        internal static WorkspaceSku DeserializeWorkspaceSku(JsonElement element)
        {
            Optional <IReadOnlyList <string> > locations = default;
            Optional <IReadOnlyList <ResourceSkuLocationInfo> > locationInfo = default;
            Optional <string> tier         = default;
            Optional <string> resourceType = default;
            Optional <string> name         = default;
            Optional <IReadOnlyList <SKUCapability> > capabilities = default;
            Optional <IReadOnlyList <Restriction> >   restrictions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("locations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    locations = array;
                    continue;
                }
                if (property.NameEquals("locationInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ResourceSkuLocationInfo> array = new List <ResourceSkuLocationInfo>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ResourceSkuLocationInfo.DeserializeResourceSkuLocationInfo(item));
                    }
                    locationInfo = array;
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    tier = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceType"))
                {
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SKUCapability> array = new List <SKUCapability>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SKUCapability.DeserializeSKUCapability(item));
                    }
                    capabilities = array;
                    continue;
                }
                if (property.NameEquals("restrictions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Restriction> array = new List <Restriction>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Restriction.DeserializeRestriction(item));
                    }
                    restrictions = array;
                    continue;
                }
            }
            return(new WorkspaceSku(Optional.ToList(locations), Optional.ToList(locationInfo), tier.Value, resourceType.Value, name.Value, Optional.ToList(capabilities), Optional.ToList(restrictions)));
        }