Exemplo n.º 1
0
        internal static Sku DeserializeSku(JsonElement element)
        {
            SkuName            name     = default;
            Optional <SkuTier> tier     = default;
            Optional <int>     capacity = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = new SkuName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    tier = new SkuTier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("capacity"))
                {
                    capacity = property.Value.GetInt32();
                    continue;
                }
            }
            return(new Sku(name, Optional.ToNullable(tier), Optional.ToNullable(capacity)));
        }
        internal static Sku DeserializeSku(JsonElement element)
        {
            SkuName name     = default;
            SkuTier?tier     = default;
            int?    capacity = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = new SkuName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    tier = new SkuTier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("capacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    capacity = property.Value.GetInt32();
                    continue;
                }
            }
            return(new Sku(name, tier, capacity));
        }