Exemplo n.º 1
0
        internal static EventProperty DeserializeEventProperty(JsonElement element)
        {
            Optional <string>        name = default;
            Optional <PropertyTypes> type = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new PropertyTypes(property.Value.GetString());
                    continue;
                }
            }
            return(new EventProperty(name.Value, Optional.ToNullable(type)));
        }
Exemplo n.º 2
0
        internal static PropertyValues DeserializePropertyValues(JsonElement element)
        {
            Optional <IList <object> > values = default;
            Optional <string>          name   = default;
            Optional <PropertyTypes>   type   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("values"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <object> array = new List <object>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetObject());
                    }
                    values = array;
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new PropertyTypes(property.Value.GetString());
                    continue;
                }
            }
            return(new PropertyValues(name.Value, Optional.ToNullable(type), Optional.ToList(values)));
        }