public CronFieldListItem(int fieldPos, string part) { FieldPos = fieldPos; this.part = part; values = new int[2] { -1, -1 }; if (part.IndexOf("0/") == 0) { Type = CronFieldType.Periodic; string s = part.Replace("0/", ""); if (!int.TryParse(s, out values[0])) { throw new ArgumentException("Periodic value assigned is not numeric"); } } else if (part.IndexOf('-') > 0) { Type = CronFieldType.Range; string[] array = part.Split('-'); values[0] = CronUtils.ConvertCronFieldToNumber(fieldPos, array[0]); values[1] = CronUtils.ConvertCronFieldToNumber(fieldPos, array[1]); } else if (part == "*") { Type = CronFieldType.Wildcard; values[0] = 0; } else { Type = CronFieldType.Single; values[0] = CronUtils.ConvertCronFieldToNumber(fieldPos, part); } }
private static bool isCronTimeForField(int fieldPos, string fieldValue, string timeValue) { bool result = false; int num = CronUtils.ConvertCronFieldToNumber(fieldPos, timeValue); string[] array = fieldValue.Split(','); foreach (string text in array) { if (text.IndexOf("0/") == 0) { string str = text.Replace("0/", ""); int num2 = CronUtils.ConvertCronFieldToNumber(fieldPos, str); if (num2 != 0 && num % num2 == 0) { result = true; break; } } else if (text.IndexOf('-') >= 0) { string[] dashSplit = text.Split('-'); getMinMaxValuesForRange(fieldPos, dashSplit, out var minRangeNumValue, out var maxRangeNumValue); if (minRangeNumValue <= num && num <= maxRangeNumValue) { result = true; break; } } else { int num3 = CronUtils.ConvertCronFieldToNumber(fieldPos, text); if (num3 == num) { result = true; break; } } } return(result); }
private static void getMinMaxValuesForRange(int fieldPos, string[] dashSplit, out int minRangeNumValue, out int maxRangeNumValue) { minRangeNumValue = CronUtils.ConvertCronFieldToNumber(fieldPos, dashSplit[0]); maxRangeNumValue = CronUtils.ConvertCronFieldToNumber(fieldPos, dashSplit[1]); }
private int getDateValueForField(int fieldPos, DateTime dateTime) { string[] array = dateTime.ToString("s m H d M ddd yyyy").Split(' '); return(CronUtils.ConvertCronFieldToNumber(fieldPos, array[fieldPos])); }