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); }
public CronField(CronFieldType type, CronFieldKind kind, DateField dateField, string spec) { Type = type; Kind = kind; DateField = dateField; Spec = spec; }
public static DateField Next(this DateField field) { if (field.Index == All.Length - 1) { return(null); } return(All[field.Index + 1]); }
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
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); } } }
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 } } }
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