internal static DateTimeResolution DeserializeDateTimeResolution(JsonElement element)
        {
            string                      timex           = default;
            DateTimeSubKind             dateTimeSubKind = default;
            string                      value           = default;
            Optional <TemporalModifier> modifier        = default;
            ResolutionKind              resolutionKind  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("timex"))
                {
                    timex = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dateTimeSubKind"))
                {
                    dateTimeSubKind = new DateTimeSubKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("modifier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modifier = new TemporalModifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new DateTimeResolution(resolutionKind, timex, dateTimeSubKind, value, Optional.ToNullable(modifier)));
        }
Пример #2
0
        internal static TemporalSpanResolution DeserializeTemporalSpanResolution(JsonElement element)
        {
            Optional <string>           begin    = default;
            Optional <string>           end      = default;
            Optional <string>           duration = default;
            Optional <TemporalModifier> modifier = default;
            ResolutionKind resolutionKind        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("begin"))
                {
                    begin = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("end"))
                {
                    end = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("duration"))
                {
                    duration = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("modifier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modifier = new TemporalModifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new TemporalSpanResolution(resolutionKind, begin.Value, end.Value, duration.Value, Optional.ToNullable(modifier)));
        }