internal TagDetails(string id, string tagName, TagCount count, IReadOnlyList <TagValue> values)
 {
     Id      = id;
     TagName = tagName;
     Count   = count;
     Values  = values;
 }
        internal static TagValue DeserializeTagValue(JsonElement element)
        {
            Optional <string>   id       = default;
            Optional <string>   tagValue = default;
            Optional <TagCount> 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"))
                {
                    count = TagCount.DeserializeTagCount(property.Value);
                    continue;
                }
            }
            return(new TagValue(id.Value, tagValue.Value, count.Value));
        }
Example #3
0
        internal static TagDetails DeserializeTagDetails(JsonElement element)
        {
            string   id      = default;
            string   tagName = default;
            TagCount count   = default;
            IReadOnlyList <TagValue> values = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tagName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    tagName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    count = TagCount.DeserializeTagCount(property.Value);
                    continue;
                }
                if (property.NameEquals("values"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <TagValue> array = new List <TagValue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(TagValue.DeserializeTagValue(item));
                        }
                    }
                    values = array;
                    continue;
                }
            }
            return(new TagDetails(id, tagName, count, values));
        }
        internal static TagValue DeserializeTagValue(JsonElement element)
        {
            string   id       = default;
            string   tagValue = default;
            TagCount count    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tagValue"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    tagValue = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    count = TagCount.DeserializeTagCount(property.Value);
                    continue;
                }
            }
            return(new TagValue(id, tagValue, count));
        }
        internal static TagDetails DeserializeTagDetails(JsonElement element)
        {
            Optional <string>   id      = default;
            Optional <string>   tagName = default;
            Optional <TagCount> count   = default;
            Optional <IReadOnlyList <TagValue> > 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"))
                {
                    count = TagCount.DeserializeTagCount(property.Value);
                    continue;
                }
                if (property.NameEquals("values"))
                {
                    List <TagValue> array = new List <TagValue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TagValue.DeserializeTagValue(item));
                    }
                    values = array;
                    continue;
                }
            }
            return(new TagDetails(id.Value, tagName.Value, count.Value, Optional.ToList(values)));
        }