public CrontabValueHourMinuteGroup(CronMinuteValue minute, CronHourValue hour) { this.minute = minute; this.hour = hour; }
public static bool TryParse(string value, out CronHourValue crontabValue) { crontabValue = null; var list = new List <CronNodeBase>(); var array = value.Split(Separator, StringSplitOptions.RemoveEmptyEntries); foreach (var item in array) { if (item == "*" || item == "*/1") { crontabValue = new CronHourValue(null); return(true); } if (int.TryParse(item, out int data)) { if (data >= min && data <= max) { list.Add(new SingleCrontabValueNode(data)); continue; } else { return(false); } } var aftmatch = AllFromToRegex.Match(item); if (aftmatch.Success) { var interval = Convert.ToInt32(aftmatch.Groups["interval"].Value); if (interval > 0) { list.Add(new RangeCrontabValueNode(min, max, min, max, interval)); continue; } else { return(false); } } var ftmatch = FromToRegex.Match(item); if (ftmatch.Success) { var start = Convert.ToInt32(ftmatch.Groups["start"].Value); var end = Convert.ToInt32(ftmatch.Groups["end"].Value); var interval = 1; if (ftmatch.Groups["interval"].Success) { interval = Convert.ToInt32(ftmatch.Groups["interval"].Value); } if (start >= min && start <= max && end >= min && end <= max && interval > 0) { list.Add(new RangeCrontabValueNode(min, max, start, end, interval)); continue; } else { return(false); } } return(false); } if (list.Count == 0) { return(false); } else { crontabValue = new CronHourValue(list); return(true); } }