예제 #1
0
        internal static ResourceSkuLocationInfo DeserializeResourceSkuLocationInfo(JsonElement element)
        {
            Optional <string> location = default;
            Optional <IReadOnlyList <string> > zones = default;
            Optional <IReadOnlyList <ResourceSkuZoneDetails> > zoneDetails = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    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());
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("zoneDetails"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ResourceSkuZoneDetails> array = new List <ResourceSkuZoneDetails>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ResourceSkuZoneDetails.DeserializeResourceSkuZoneDetails(item));
                    }
                    zoneDetails = array;
                    continue;
                }
            }
            return(new ResourceSkuLocationInfo(location.Value, Optional.ToList(zones), Optional.ToList(zoneDetails)));
        }
예제 #2
0
        internal static ComputeResourceSkuLocationInfo DeserializeComputeResourceSkuLocationInfo(JsonElement element)
        {
            Optional <AzureLocation>           location = default;
            Optional <IReadOnlyList <string> > zones    = default;
            Optional <IReadOnlyList <ResourceSkuZoneDetails> > zoneDetails = default;
            Optional <IReadOnlyList <string> > extendedLocations           = default;
            Optional <ExtendedLocationType>    type = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    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());
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("zoneDetails"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ResourceSkuZoneDetails> array = new List <ResourceSkuZoneDetails>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ResourceSkuZoneDetails.DeserializeResourceSkuZoneDetails(item));
                    }
                    zoneDetails = array;
                    continue;
                }
                if (property.NameEquals("extendedLocations"))
                {
                    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());
                    }
                    extendedLocations = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new ExtendedLocationType(property.Value.GetString());
                    continue;
                }
            }
            return(new ComputeResourceSkuLocationInfo(Optional.ToNullable(location), Optional.ToList(zones), Optional.ToList(zoneDetails), Optional.ToList(extendedLocations), Optional.ToNullable(type)));
        }
        internal static ResourceSkuLocationInfo DeserializeResourceSkuLocationInfo(JsonElement element)
        {
            string location = default;
            IReadOnlyList <string> zones = default;
            IReadOnlyList <ResourceSkuZoneDetails> zoneDetails = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("zoneDetails"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ResourceSkuZoneDetails> array = new List <ResourceSkuZoneDetails>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ResourceSkuZoneDetails.DeserializeResourceSkuZoneDetails(item));
                        }
                    }
                    zoneDetails = array;
                    continue;
                }
            }
            return(new ResourceSkuLocationInfo(location, zones, zoneDetails));
        }