예제 #1
0
 public IntCronField(CronFieldType type, CronFieldKind kind, DateField dateField, string spec, params int[] values)
     : base(type, kind, dateField, spec)
 {
     Values = values;
     // For day field 31 matches last day of the month
     _matchLastDay = type == CronFieldType.Day && kind != CronFieldKind.AnyValue && values.Contains(31);
 }
예제 #2
0
 public CronField(CronFieldType type, CronFieldKind kind, DateField dateField, string spec)
 {
     Type      = type;
     Kind      = kind;
     DateField = dateField;
     Spec      = spec;
 }
예제 #3
0
 public static DateField Next(this DateField field)
 {
     if (field.Index == All.Length - 1)
     {
         return(null);
     }
     return(All[field.Index + 1]);
 }
예제 #4
0
 private bool TryIncrement(DateField dateField, DateValue date)
 {
     if (!dateField.TryIncrement(date))
     {
         return(false);
     }
     // if we incremented, reset all following fields
     for (int i = dateField.Index + 1; i < DateFields.All.Length; i++)
     {
         DateFields.All[i].Reset(date);
     }
     return(true);
 } //method
예제 #5
0
        private bool TryFindMatch(DateField dateField, DateValue date)
        {
            var cronFields = _fieldsByDateFieldType[dateField.Index];

            while (true)
            {
                if (cronFields.All(cf => cf.Matches(date)))
                {
                    return(true);
                }
                if (!TryIncrement(dateField, date))
                {
                    return(false);
                }
            }
        }
예제 #6
0
 private bool TryMatchAllStartingWith(DateField startingWith, DateValue date)
 {
     if (startingWith == null)
     {
         return(true);
     }
     while (true)
     {
         if (TryFindMatch(startingWith, date) && TryMatchAllStartingWith(startingWith.Next(), date))
         {
             return(true);
         }
         if (!TryIncrement(startingWith, date))
         {
             return(false); //we are out of increments for this level
         }
     }
 }
예제 #7
0
        public override bool Matches(DateValue date)
        {
            var value = GetFieldValue(date);

            if (_matchLastDay && value == DateField.GetMax(date))
            {
                return(true);
            }
            switch (Kind)
            {
            case CronFieldKind.AnyValue: return(true);

            case CronFieldKind.Value:
                return(value == this.Values[0]);

            case CronFieldKind.Range: return(value >= this.Values[0] && value <= this.Values[1]);

            case CronFieldKind.List: return(Values.Contains(value));

            default:
                return(false);
            }
        } //method