Ejemplo n.º 1
0
 internal DateTimeResolution(ResolutionKind resolutionKind, string timex, DateTimeSubKind dateTimeSubKind, string value, TemporalModifier?modifier) : base(resolutionKind)
 {
     Timex           = timex;
     DateTimeSubKind = dateTimeSubKind;
     Value           = value;
     Modifier        = modifier;
     ResolutionKind  = resolutionKind;
 }
Ejemplo n.º 2
0
        internal DateTimeResolution(string timex, DateTimeSubKind dateTimeSubKind, string value)
        {
            if (timex == null)
            {
                throw new ArgumentNullException(nameof(timex));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            Timex           = timex;
            DateTimeSubKind = dateTimeSubKind;
            Value           = value;
            ResolutionKind  = ResolutionKind.DateTime;
        }
        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)));
        }
 public static DateTimeResolution DateTimeResolution(ResolutionKind resolutionKind = default, string timex = null, DateTimeSubKind dateTimeSubKind = default, string value = null, TemporalModifier?modifier = null)
 {
     return(new DateTimeResolution(resolutionKind, timex, dateTimeSubKind, value, modifier));
 }