Пример #1
0
 internal CurrencyResolution(ResolutionKind resolutionKind, string isO4217, string unit, double value) : base(resolutionKind)
 {
     ISO4217        = isO4217;
     Unit           = unit;
     Value          = value;
     ResolutionKind = resolutionKind;
 }
Пример #2
0
        internal static SpeedResolution DeserializeSpeedResolution(JsonElement element)
        {
            SpeedUnit      unit           = default;
            double         value          = default;
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("unit"))
                {
                    unit = new SpeedUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new SpeedResolution(resolutionKind, unit, value));
        }
 internal OrdinalResolution(ResolutionKind resolutionKind, string offset, RelativeTo relativeTo, string value) : base(resolutionKind)
 {
     Offset         = offset;
     RelativeTo     = relativeTo;
     Value          = value;
     ResolutionKind = resolutionKind;
 }
        internal static CurrencyResolution DeserializeCurrencyResolution(JsonElement element)
        {
            Optional <string> isO4217        = default;
            string            unit           = default;
            double            value          = default;
            ResolutionKind    resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ISO4217"))
                {
                    isO4217 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new CurrencyResolution(resolutionKind, isO4217.Value, unit, value));
        }
Пример #5
0
        internal static NumericRangeResolution DeserializeNumericRangeResolution(JsonElement element)
        {
            RangeKind      rangeKind      = default;
            double         minimum        = default;
            double         maximum        = default;
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("rangeKind"))
                {
                    rangeKind = new RangeKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("minimum"))
                {
                    minimum = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("maximum"))
                {
                    maximum = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new NumericRangeResolution(resolutionKind, rangeKind, minimum, maximum));
        }
        internal static NumberResolution DeserializeNumberResolution(JsonElement element)
        {
            NumberKind     numberKind     = default;
            string         value          = default;
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("numberKind"))
                {
                    numberKind = new NumberKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new NumberResolution(resolutionKind, numberKind, value));
        }
        internal static OrdinalResolution DeserializeOrdinalResolution(JsonElement element)
        {
            string         offset         = default;
            RelativeTo     relativeTo     = default;
            string         value          = default;
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("offset"))
                {
                    offset = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("relativeTo"))
                {
                    relativeTo = new RelativeTo(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new OrdinalResolution(resolutionKind, offset, relativeTo, value));
        }
Пример #8
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;
 }
        internal static BaseResolution DeserializeBaseResolution(JsonElement element)
        {
            if (element.TryGetProperty("resolutionKind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Age": return(AgeResolution.DeserializeAgeResolution(element));

                case "Area": return(AreaResolution.DeserializeAreaResolution(element));

                case "Boolean": return(BooleanResolution.DeserializeBooleanResolution(element));

                case "Currency": return(CurrencyResolution.DeserializeCurrencyResolution(element));

                case "DateTime": return(DateTimeResolution.DeserializeDateTimeResolution(element));

                case "Information": return(InformationResolution.DeserializeInformationResolution(element));

                case "Length": return(LengthResolution.DeserializeLengthResolution(element));

                case "Number": return(NumberResolution.DeserializeNumberResolution(element));

                case "NumericRange": return(NumericRangeResolution.DeserializeNumericRangeResolution(element));

                case "Ordinal": return(OrdinalResolution.DeserializeOrdinalResolution(element));

                case "Speed": return(SpeedResolution.DeserializeSpeedResolution(element));

                case "Temperature": return(TemperatureResolution.DeserializeTemperatureResolution(element));

                case "TemporalSpan": return(TemporalSpanResolution.DeserializeTemporalSpanResolution(element));

                case "Volume": return(VolumeResolution.DeserializeVolumeResolution(element));

                case "Weight": return(WeightResolution.DeserializeWeightResolution(element));
                }
            }
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new BaseResolution(resolutionKind));
        }
Пример #10
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)));
        }
        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)));
        }
        internal static BooleanResolution DeserializeBooleanResolution(JsonElement element)
        {
            bool           value          = default;
            ResolutionKind resolutionKind = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("resolutionKind"))
                {
                    resolutionKind = new ResolutionKind(property.Value.GetString());
                    continue;
                }
            }
            return(new BooleanResolution(resolutionKind, value));
        }
 public static NumberResolution NumberResolution(ResolutionKind resolutionKind = default, NumberKind numberKind = default, string value = null)
 {
     return(new NumberResolution(resolutionKind, numberKind, value));
 }
 public static SpeedResolution SpeedResolution(ResolutionKind resolutionKind = default, SpeedUnit unit = default, double value = default)
 {
     return(new SpeedResolution(resolutionKind, unit, value));
 }
 public static AreaResolution AreaResolution(ResolutionKind resolutionKind = default, AreaUnit unit = default, double value = default)
 {
     return(new AreaResolution(resolutionKind, unit, value));
 }
 public static LengthResolution LengthResolution(ResolutionKind resolutionKind = default, LengthUnit unit = default, double value = default)
 {
     return(new LengthResolution(resolutionKind, unit, value));
 }
Пример #17
0
 internal NumberResolution(ResolutionKind resolutionKind, NumberKind numberKind, string value) : base(resolutionKind)
 {
     NumberKind     = numberKind;
     Value          = value;
     ResolutionKind = resolutionKind;
 }
 public static InformationResolution InformationResolution(ResolutionKind resolutionKind = default, InformationUnit unit = default, double value = default)
 {
     return(new InformationResolution(resolutionKind, unit, value));
 }
 public static NumericRangeResolution NumericRangeResolution(ResolutionKind resolutionKind = default, RangeKind rangeKind = default, double minimum = default, double maximum = default)
 {
     return(new NumericRangeResolution(resolutionKind, rangeKind, minimum, maximum));
 }
 public static TemporalSpanResolution TemporalSpanResolution(ResolutionKind resolutionKind = default, string begin = null, string end = null, string duration = null, TemporalModifier?modifier = null)
 {
     return(new TemporalSpanResolution(resolutionKind, begin, end, duration, modifier));
 }
 public static VolumeResolution VolumeResolution(ResolutionKind resolutionKind = default, VolumeUnit unit = default, double value = default)
 {
     return(new VolumeResolution(resolutionKind, unit, value));
 }
 public static TemperatureResolution TemperatureResolution(ResolutionKind resolutionKind = default, TemperatureUnit unit = default, double value = default)
 {
     return(new TemperatureResolution(resolutionKind, unit, value));
 }
 public static BooleanResolution BooleanResolution(ResolutionKind resolutionKind = default, bool value = default)
 {
     return(new BooleanResolution(resolutionKind, value));
 }
 public static CurrencyResolution CurrencyResolution(ResolutionKind resolutionKind = default, string isO4217 = null, string unit = null, double value = default)
 {
     return(new CurrencyResolution(resolutionKind, isO4217, unit, value));
 }
 public static WeightResolution WeightResolution(ResolutionKind resolutionKind = default, WeightUnit unit = default, double value = default)
 {
     return(new WeightResolution(resolutionKind, unit, value));
 }
 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));
 }
 public static OrdinalResolution OrdinalResolution(ResolutionKind resolutionKind = default, string offset = null, RelativeTo relativeTo = default, string value = null)
 {
     return(new OrdinalResolution(resolutionKind, offset, relativeTo, value));
 }