Beispiel #1
0
        internal static SkuInfo DeserializeSkuInfo(JsonElement element)
        {
            Optional <string>         resourceType = default;
            Optional <SkuDescription> sku          = default;
            Optional <SkuCapacity>    capacity     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("resourceType"))
                {
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = SkuDescription.DeserializeSkuDescription(property.Value);
                    continue;
                }
                if (property.NameEquals("capacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    capacity = SkuCapacity.DeserializeSkuCapacity(property.Value);
                    continue;
                }
            }
            return(new SkuInfo(resourceType.Value, sku.Value, capacity.Value));
        }
Beispiel #2
0
        internal static SkuDescription DeserializeSkuDescription(JsonElement element)
        {
            Optional <string>              name         = default;
            Optional <string>              tier         = default;
            Optional <string>              size         = default;
            Optional <string>              family       = default;
            Optional <int>                 capacity     = default;
            Optional <SkuCapacity>         skuCapacity  = default;
            Optional <IList <string> >     locations    = default;
            Optional <IList <Capability> > capabilities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    tier = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("size"))
                {
                    size = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("family"))
                {
                    family = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("capacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    capacity = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("skuCapacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    skuCapacity = SkuCapacity.DeserializeSkuCapacity(property.Value);
                    continue;
                }
                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("capabilities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Capability> array = new List <Capability>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Capability.DeserializeCapability(item));
                    }
                    capabilities = array;
                    continue;
                }
            }
            return(new SkuDescription(name.Value, tier.Value, size.Value, family.Value, Optional.ToNullable(capacity), skuCapacity.Value, Optional.ToList(locations), Optional.ToList(capabilities)));
        }