Esempio n. 1
0
 public DateRangeQueryDescriptor <T> LessThan(DateMath to) => Assign(to, (a, v) => a.LessThan = v);
Esempio n. 2
0
 public DateRangeQueryDescriptor <T> LessThanOrEquals(DateMath to) => Assign(to, (a, v) => a.LessThanOrEqualTo = v);
Esempio n. 3
0
 public DateRangeQueryDescriptor <T> GreaterThanOrEquals(DateMath from) => Assign(from, (a, v) => a.GreaterThanOrEqualTo = v);
 /// <inheritdoc cref="IDistanceFeatureQuery.Origin" />
 public DistanceFeatureQueryDescriptor <T> Origin(DateMath origin) =>
 Assign(origin, (a, v) => a.Origin = v);
Esempio n. 5
0
        public IRangeQuery Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver)
        {
            if (reader.ReadIsNull())
            {
                return(null);
            }

            var segment       = reader.ReadNextBlockSegment();
            var segmentReader = new JsonReader(segment.Array, segment.Offset);
            var isLong        = false;
            var isDate        = false;
            var isDouble      = false;
            var count         = 0;

            while (segmentReader.ReadIsInObject(ref count))
            {
                segmentReader.ReadPropertyNameSegmentRaw();

                var innerCount = 0;
                while (segmentReader.ReadIsInObject(ref innerCount))
                {
                    var innerPropertyName = segmentReader.ReadPropertyNameSegmentRaw();
                    if (RangeFields.TryGetValue(innerPropertyName, out var innerValue))
                    {
                        switch (innerValue)
                        {
                        case 0:
                        case 1:
                            isDate = true;
                            break;

                        case 2:
                        case 3:
                        case 4:
                        case 5:
                            var token = segmentReader.GetCurrentJsonToken();
                            switch (token)
                            {
                            case JsonToken.String:
                            case JsonToken.Null:
                                if (!isDate)
                                {
                                    var valueSegment = segmentReader.ReadStringSegmentUnsafe();
                                    isDate = valueSegment.IsDateTime(formatterResolver, out _) ||
                                             valueSegment.ContainsDateMathSeparator() && DateMath.IsValidDateMathString(valueSegment.Utf8String());
                                }
                                break;

                            case JsonToken.Number:
                                if (!isDouble)
                                {
                                    var numberSegment = segmentReader.ReadNumberSegment();
                                    if (numberSegment.IsDouble())
                                    {
                                        isDouble = true;
                                    }
                                    else
                                    {
                                        isLong = true;
                                    }
                                }
                                break;
                            }
                            break;
                        }
                    }
                    else
                    {
                        segmentReader.ReadNextBlock();
                    }

                    if (isDate || isDouble)
                    {
                        break;
                    }
                }

                if (isDate || isDouble)
                {
                    break;
                }
            }

            segmentReader = new JsonReader(segment.Array, segment.Offset);

            if (isDate)
            {
                return(Deserialize <IDateRangeQuery>(ref segmentReader, formatterResolver));
            }
            if (isDouble)
            {
                return(Deserialize <INumericRangeQuery>(ref segmentReader, formatterResolver));
            }
            if (isLong)
            {
                return(Deserialize <ILongRangeQuery>(ref segmentReader, formatterResolver));
            }

            return(Deserialize <ITermRangeQuery>(ref segmentReader, formatterResolver));
        }
 public DateRangeExpressionDescriptor To(DateMath to) => Assign(to, (a, v) => a.To = v);
 public DateRangeExpressionDescriptor From(DateMath from) => Assign(from, (a, v) => a.From = v);