Exemple #1
0
 public IntervalComputerConstantCoincides(IntervalStartEndParameterPair pair)
 {
     Start = pair.Start.OptionalConstant.GetValueOrDefault();
     End   = pair.End.OptionalConstant.GetValueOrDefault();
     if (Start < 0 || End < 0)
     {
         throw new ExprValidationException(
                   "The coincides date-time method does not allow negative start and end values");
     }
 }
Exemple #2
0
 public IntervalComputerCoincidesWithDeltaExpr(IntervalStartEndParameterPair pair)
 {
     _start  = pair.Start.Evaluator;
     _finish = pair.End.Evaluator;
 }
Exemple #3
0
 public IntervalComputerConstantBefore(IntervalStartEndParameterPair pair)
     : base(pair, true)
 {
 }
Exemple #4
0
        public static IntervalComputer Make(DatetimeMethodEnum method, IList <ExprNode> expressions, TimeAbacus timeAbacus)
        {
            var parameters = GetParameters(expressions, timeAbacus);

            if (method == DatetimeMethodEnum.BEFORE)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerBeforeNoParam());
                }
                var pair = IntervalStartEndParameterPair.FromParamsWithLongMaxEnd(parameters);
                if (pair.IsConstant)
                {
                    return(new IntervalComputerConstantBefore(pair));
                }
                return(new IntervalComputerBeforeWithDeltaExpr(pair));
            }
            else if (method == DatetimeMethodEnum.AFTER)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerAfterNoParam());
                }
                var pair = IntervalStartEndParameterPair.FromParamsWithLongMaxEnd(parameters);
                if (pair.IsConstant)
                {
                    return(new IntervalComputerConstantAfter(pair));
                }
                return(new IntervalComputerAfterWithDeltaExpr(pair));
            }
            else if (method == DatetimeMethodEnum.COINCIDES)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerCoincidesNoParam());
                }
                var pair = IntervalStartEndParameterPair.FromParamsWithSameEnd(parameters);
                if (pair.IsConstant)
                {
                    return(new IntervalComputerConstantCoincides(pair));
                }
                return(new IntervalComputerCoincidesWithDeltaExpr(pair));
            }
            else if (method == DatetimeMethodEnum.DURING || method == DatetimeMethodEnum.INCLUDES)
            {
                if (parameters.Length == 0)
                {
                    if (method == DatetimeMethodEnum.DURING)
                    {
                        return(new IntervalComputerDuringNoParam());
                    }
                    return(new IntervalComputerIncludesNoParam());
                }
                var pair = IntervalStartEndParameterPair.FromParamsWithSameEnd(parameters);
                if (parameters.Length == 1)
                {
                    return(new IntervalComputerDuringAndIncludesThreshold(
                               method == DatetimeMethodEnum.DURING, pair.Start.Evaluator));
                }
                if (parameters.Length == 2)
                {
                    return(new IntervalComputerDuringAndIncludesMinMax(
                               method == DatetimeMethodEnum.DURING, pair.Start.Evaluator, pair.End.Evaluator));
                }
                return(new IntervalComputerDuringMinMaxStartEnd(
                           method == DatetimeMethodEnum.DURING, GetEvaluators(expressions, timeAbacus)));
            }
            else if (method == DatetimeMethodEnum.FINISHES)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerFinishesNoParam());
                }
                ValidateConstantThreshold("finishes", parameters[0]);
                return(new IntervalComputerFinishesThreshold(parameters[0].Evaluator));
            }
            else if (method == DatetimeMethodEnum.FINISHEDBY)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerFinishedByNoParam());
                }
                ValidateConstantThreshold("finishedby", parameters[0]);
                return(new IntervalComputerFinishedByThreshold(parameters[0].Evaluator));
            }
            else if (method == DatetimeMethodEnum.MEETS)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerMeetsNoParam());
                }
                ValidateConstantThreshold("meets", parameters[0]);
                return(new IntervalComputerMeetsThreshold(parameters[0].Evaluator));
            }
            else if (method == DatetimeMethodEnum.METBY)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerMetByNoParam());
                }
                ValidateConstantThreshold("metBy", parameters[0]);
                return(new IntervalComputerMetByThreshold(parameters[0].Evaluator));
            }
            else if (method == DatetimeMethodEnum.OVERLAPS || method == DatetimeMethodEnum.OVERLAPPEDBY)
            {
                if (parameters.Length == 0)
                {
                    if (method == DatetimeMethodEnum.OVERLAPS)
                    {
                        return(new IntervalComputerOverlapsNoParam());
                    }
                    return(new IntervalComputerOverlappedByNoParam());
                }
                if (parameters.Length == 1)
                {
                    return(new IntervalComputerOverlapsAndByThreshold(
                               method == DatetimeMethodEnum.OVERLAPS, parameters[0].Evaluator));
                }
                return(new IntervalComputerOverlapsAndByMinMax(
                           method == DatetimeMethodEnum.OVERLAPS, parameters[0].Evaluator, parameters[1].Evaluator));
            }
            else if (method == DatetimeMethodEnum.STARTS)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerStartsNoParam());
                }
                ValidateConstantThreshold("starts", parameters[0]);
                return(new IntervalComputerStartsThreshold(parameters[0].Evaluator));
            }
            else if (method == DatetimeMethodEnum.STARTEDBY)
            {
                if (parameters.Length == 0)
                {
                    return(new IntervalComputerStartedByNoParam());
                }
                ValidateConstantThreshold("startedBy", parameters[0]);
                return(new IntervalComputerStartedByThreshold(parameters[0].Evaluator));
            }
            throw new ArgumentException("Unknown datetime method '" + method + "'");
        }