internal static PredefinedTagValue DeserializeTagValue(JsonElement element)
        {
            Optional <string>             id       = default;
            Optional <string>             tagValue = default;
            Optional <PredefinedTagCount> count    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tagValue"))
                {
                    tagValue = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = PredefinedTagCount.DeserializeTagCount(property.Value);
                    continue;
                }
            }
            return(new PredefinedTagValue(id.Value, tagValue.Value, count.Value));
        }
示例#2
0
 internal PredefinedTag(string id, string tagName, PredefinedTagCount count, IReadOnlyList <PredefinedTagValue> values)
 {
     Id      = id;
     TagName = tagName;
     Count   = count;
     Values  = values;
 }
示例#3
0
        internal static PredefinedTag DeserializePredefinedTag(JsonElement element)
        {
            Optional <string>             id      = default;
            Optional <string>             tagName = default;
            Optional <PredefinedTagCount> count   = default;
            Optional <IReadOnlyList <PredefinedTagValue> > values = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tagName"))
                {
                    tagName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = PredefinedTagCount.DeserializePredefinedTagCount(property.Value);
                    continue;
                }
                if (property.NameEquals("values"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <PredefinedTagValue> array = new List <PredefinedTagValue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PredefinedTagValue.DeserializePredefinedTagValue(item));
                    }
                    values = array;
                    continue;
                }
            }
            return(new PredefinedTag(id.Value, tagName.Value, count.Value, Optional.ToList(values)));
        }