Ejemplo n.º 1
0
        internal static CdnUsage DeserializeCdnUsage(JsonElement element)
        {
            Optional <ResourceIdentifier> id = default;
            UsageUnit unit         = default;
            long      currentValue = default;
            long      limit        = default;
            UsageName name         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = new UsageUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("currentValue"))
                {
                    currentValue = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("limit"))
                {
                    limit = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = UsageName.DeserializeUsageName(property.Value);
                    continue;
                }
            }
            return(new CdnUsage(id.Value, unit, currentValue, limit, name));
        }
Ejemplo n.º 2
0
        internal static CdnUsage DeserializeCdnUsage(JsonElement element)
        {
            Optional <string> id   = default;
            UsageUnit         unit = default;
            long      currentValue = default;
            long      limit        = default;
            UsageName name         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = new UsageUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("currentValue"))
                {
                    currentValue = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("limit"))
                {
                    limit = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = UsageName.DeserializeUsageName(property.Value);
                    continue;
                }
            }
            return(new CdnUsage(id.Value, unit, currentValue, limit, name));
        }