Exemple #1
0
        ///////////////////////////////////////////////////////////////////////
        // based loosely on perl's Set::Crontab parsing routine
        private static void Expand(String str, CronSet set)
        {
            foreach (String part in str.Split(',')) {
                Match match = CronPartRE.Match(part);

                int step = 1;
                if (match.Groups["s"].Success) {
                    String val = match.Groups["s"].Value;
                    step = int.Parse(val);
                }

                if (match.Groups["n"].Success) {
                    String val = match.Groups["n"].Value;
                    set[int.Parse(val)] = true;

                } else if (match.Groups["m"].Value == "*") {
                    for (int idx = set._min; idx <= set._max; idx++) {
                        if (idx % step == 0) { set[idx] = true; }
                    }

                } else if (match.Groups["r"].Success) {
                    int start = int.Parse(match.Groups["rb"].Value);
                    int stop = int.Parse(match.Groups["re"].Value);
                    for (int idx = start; idx <= stop; idx++) {
                        if (idx % step == 0) { set[idx] = true; }
                    }
                }
            }
        }
Exemple #2
0
 ///////////////////////////////////////////////////////////////////////
 public static CronSet Parse(String str, int min, int max)
 {
     CronSet set = new CronSet(min, max);
     Expand(str, set);
     set._orig = str;
     return set;
 }