Exemplo n.º 1
0
        public static bool TryParse(string value, out CronTimeRangeValue timeRange)
        {
            timeRange = null;
            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }
            string[] rangearr = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            if (rangearr.Length == 0)
            {
                return(false);
            }

            List <TimeRange> list = new List <TimeRange>();

            foreach (var item in rangearr)
            {
                var match = regex.Match(item);
                if (match.Success)
                {
                    var fromHour   = Convert.ToInt32(match.Groups["fromHour"].Value);
                    var fromMinute = Convert.ToInt32(match.Groups["fromMinute"].Value);
                    var toHour     = Convert.ToInt32(match.Groups["toHour"].Value);
                    var toMinute   = Convert.ToInt32(match.Groups["toMinute"].Value);
                    var interval   = 1;
                    if (match.Groups["interval"].Success)
                    {
                        interval = Convert.ToInt32(match.Groups["interval"].Value);
                    }
                    var timerange = new TimeRange(fromHour, fromMinute, toHour, toMinute, interval);
                    list.Add(timerange);
                }
                else
                {
                    return(false);
                }
            }

            timeRange = new CronTimeRangeValue(list);
            return(true);
        }
Exemplo n.º 2
0
 public CrontabValueTimeRangeGroup(CronTimeRangeValue timeRange)
 {
     this.timeRange = timeRange;
 }