/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="kind">The crontab field kind to associate with this filter</param> public LastWeekdayOfMonthFilter(CrontabFieldKind kind) { if (kind != CrontabFieldKind.Day) throw new CrontabException("<LW> can only be used in the Day field."); Kind = kind; }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="start">The start of the range</param> /// <param name="end">The end of the range</param> /// <param name="steps">The steps in the range</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public RangeFilter(int start, int end, int? steps, CrontabFieldKind kind) { var maxValue = Constants.MaximumDateTimeValues[kind]; if (start < 0 || start > maxValue) throw new CrontabException(string.Format("Start = {0} is out of bounds for <{1}> field", start, Enum.GetName(typeof(CrontabFieldKind), kind))); if (end < 0 || end > maxValue) throw new CrontabException(string.Format("End = {0} is out of bounds for <{1}> field", end, Enum.GetName(typeof(CrontabFieldKind), kind))); if (steps != null && (steps <= 0 || steps > maxValue)) throw new CrontabException(string.Format("Steps = {0} is out of bounds for <{1}> field", steps, Enum.GetName(typeof(CrontabFieldKind), kind))); Start = start; End = end; Kind = kind; Steps = steps; var filters = new List<SpecificFilter>(); for (var evalValue = Start; evalValue <= End; evalValue++) if (IsMatch(evalValue)) filters.Add(new SpecificFilter(evalValue, Kind)); SpecificFilters = filters; }
public LastDayOfMonthFilter(CrontabFieldKind kind) { if (kind != CrontabFieldKind.Day) throw new CrontabException("The <L> filter can only be used with the Day field."); Kind = kind; }
public BlankDayOfMonthOrWeekFilter(CrontabFieldKind kind) { if (kind != CrontabFieldKind.DayOfWeek && kind != CrontabFieldKind.Day) { throw new CrontabException("The <?> filter can only be used in the Day-of-Week or Day-of-Month fields."); } Kind = kind; }
/// <summary> /// Constructs a new instance of LastDayOfWeekInMonthFilter /// </summary> /// <param name="dayOfWeek">The cron day of the week (0 = Sunday...7 = Saturday)</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public LastDayOfWeekInMonthFilter(int dayOfWeek, CrontabFieldKind kind) { if (kind != CrontabFieldKind.DayOfWeek) throw new CrontabException(string.Format("<{0}L> can only be used in the Day of Week field.", dayOfWeek)); DayOfWeek = dayOfWeek; DateTimeDayOfWeek = dayOfWeek.ToDayOfWeek(); Kind = kind; }
public static CrontabFieldImpl FromKind(CrontabFieldKind kind) { if (!Enum.IsDefined(typeof(CrontabFieldKind), kind)) { throw new ArgumentException(string.Format( "Invalid crontab field kind. Valid values are {0}.", string.Join(", ", Enum.GetNames(typeof(CrontabFieldKind)))), "kind"); } return _fieldByKind[(int)kind]; }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="specificValue">The specific value you wish to match</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public NearestWeekdayFilter(int specificValue, CrontabFieldKind kind) { if (specificValue <= 0 || specificValue > Constants.MaximumDateTimeValues[CrontabFieldKind.Day]) throw new CrontabException(string.Format("<{0}W> is out of bounds for the Day field.", specificValue)); if (kind != CrontabFieldKind.Day) throw new CrontabException(string.Format("<{0}W> can only be used in the Day field.", specificValue)); SpecificValue = specificValue; Kind = kind; }
private CrontabFieldImpl(CrontabFieldKind kind, int minValue, int maxValue, string[] names) { Debug.Assert(Enum.IsDefined(typeof(CrontabFieldKind), kind)); Debug.Assert(minValue >= 0); Debug.Assert(maxValue >= minValue); Debug.Assert(names == null || names.Length == (maxValue - minValue + 1)); _kind = kind; _minValue = minValue; _maxValue = maxValue; _names = names; }
/// <summary> /// Constructs a new instance of LastDayOfWeekInMonthFilter /// </summary> /// <param name="dayOfWeek">The cron day of the week (0 = Sunday...7 = Saturday)</param> /// <param name="weekNumber">Indicates which occurence of the day to filter against</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificDayOfWeekInMonthFilter(int dayOfWeek, int weekNumber, CrontabFieldKind kind) { if (weekNumber <= 0 || weekNumber > 5) throw new CrontabException(string.Format("Week number = {0} is out of bounds.", weekNumber)); if (kind != CrontabFieldKind.DayOfWeek) throw new CrontabException(string.Format("<{0}#{1}> can only be used in the Day of Week field.", dayOfWeek, weekNumber)); DayOfWeek = dayOfWeek; DateTimeDayOfWeek = dayOfWeek.ToDayOfWeek(); WeekNumber = weekNumber; Kind = kind; }
public static CrontabFieldImpl FromKind(CrontabFieldKind kind) { if (!Enum.IsDefined(typeof(CrontabFieldKind), kind)) { var enums = string.Join(", ", Enum.GetNames(typeof(CrontabFieldKind))); throw new ArgumentException( $"Invalid crontab field kind. Valid values are {enums}." , nameof(kind)); } return(FieldByKind[(int)kind]); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="specificValue">The specific value you wish to match</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public NearestWeekdayFilter(int specificValue, CrontabFieldKind kind) { if (specificValue <= 0 || specificValue > Constants.MaximumDateTimeValues[CrontabFieldKind.Day]) { throw new CrontabException(string.Format("<{0}W> is out of bounds for the Day field.", specificValue)); } if (kind != CrontabFieldKind.Day) { throw new CrontabException(string.Format("<{0}W> can only be used in the Day field.", specificValue)); } SpecificValue = specificValue; Kind = kind; }
/// <summary> /// Constructs a new instance of LastDayOfWeekInMonthFilter /// </summary> /// <param name="dayOfWeek">The cron day of the week (0 = Sunday...7 = Saturday)</param> /// <param name="weekNumber">Indicates which occurence of the day to filter against</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificDayOfWeekInMonthFilter(int dayOfWeek, int weekNumber, CrontabFieldKind kind) { if (weekNumber <= 0 || weekNumber > 5) { throw new CrontabException(string.Format("Week number = {0} is out of bounds.", weekNumber)); } if (kind != CrontabFieldKind.DayOfWeek) { throw new CrontabException(string.Format("<{0}#{1}> can only be used in the Day of Week field.", dayOfWeek, weekNumber)); } DayOfWeek = dayOfWeek; DateTimeDayOfWeek = dayOfWeek.ToDayOfWeek(); WeekNumber = weekNumber; Kind = kind; }
/// <summary> /// Constructs a new instance of LastDayOfWeekInMonthFilter /// </summary> /// <param name="dayOfWeek">The cron day of the week (0 = Sunday...7 = Saturday)</param> /// <param name="weekNumber">Indicates which occurence of the day to filter against</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificDayOfWeekInMonthFilter(int dayOfWeek, int weekNumber, CrontabFieldKind kind) { if (weekNumber <= 0 || weekNumber > 5) { throw new CrontabException($"Week number = {weekNumber} is out of bounds."); } if (kind != CrontabFieldKind.DayOfWeek) { throw new CrontabException($"<{dayOfWeek}#{weekNumber}> can only be used in the Day of Week field."); } DayOfWeek = dayOfWeek; _dateTimeDayOfWeek = dayOfWeek.ToDayOfWeek(); WeekNumber = weekNumber; Kind = kind; }
public void BlankDayOfMonthOrWeekFilterInvalidState() { var values = new CrontabFieldKind[] { CrontabFieldKind.Hour, CrontabFieldKind.Minute, CrontabFieldKind.Month, CrontabFieldKind.Second, CrontabFieldKind.Year }; foreach (var val in values) { Assert2.Throws <CrontabException>(() => new BlankDayOfMonthOrWeekFilter(val), "Ensure BlankDayOfMonthOrWeekFilter can't be instantiated with <{0}>", Enum.GetName(typeof(CrontabFieldKind), val)); } Assert.IsTrue(new BlankDayOfMonthOrWeekFilter(CrontabFieldKind.Day).IsMatch(DateTime.Now)); Assert.IsTrue(new BlankDayOfMonthOrWeekFilter(CrontabFieldKind.DayOfWeek).IsMatch(DateTime.UtcNow)); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="start">The start of the range</param> /// <param name="end">The end of the range</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public StepFilter(int start, int step, CrontabFieldKind kind) { var maxValue = Constants.MaximumDateTimeValues[kind]; if (step <= 0 || step > maxValue) throw new CrontabException(string.Format("Steps = {0} is out of bounds for <{1}> field", step, Enum.GetName(typeof(CrontabFieldKind), kind))); Start = start; Step = step; Kind = kind; var filters = new List<SpecificFilter>(); for (var evalValue = Start; evalValue <= maxValue; evalValue++) if (IsMatch(evalValue)) filters.Add(new SpecificFilter(evalValue, Kind)); SpecificFilters = filters; }
private static List <SpecificFilter> _GetSpecificFilters(Dictionary <CrontabFieldKind, List <ICronFilter> > filters, CrontabFieldKind kind) { return(filters[kind] .Where(x => x.GetType() == typeof(SpecificFilter)) .Cast <SpecificFilter>() .Union( filters[kind] .Where(x => x.GetType() == typeof(RangeFilter)) .SelectMany(x => ((RangeFilter)x) .SpecificFilters) ) .Union( filters[kind] .Where(x => x.GetType() == typeof(StepFilter)) .SelectMany(x => ((StepFilter)x) .SpecificFilters) ) .ToList()); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="start">The start of the range</param> /// <param name="end">The end of the range</param> /// <param name="steps">The steps in the range</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public RangeFilter(int start, int end, int?steps, CrontabFieldKind kind) { var maxValue = Constants.MaximumDateTimeValues[kind]; if (start < 0 || start > maxValue) { throw new CrontabException(string.Format("Start = {0} is out of bounds for <{1}> field", start, Enum.GetName(typeof(CrontabFieldKind), kind))); } if (end < 0 || end > maxValue) { throw new CrontabException(string.Format("End = {0} is out of bounds for <{1}> field", end, Enum.GetName(typeof(CrontabFieldKind), kind))); } if (steps != null && (steps <= 0 || steps > maxValue)) { throw new CrontabException(string.Format("Steps = {0} is out of bounds for <{1}> field", steps, Enum.GetName(typeof(CrontabFieldKind), kind))); } Start = start; End = end; Kind = kind; Steps = steps; var filters = new List <SpecificFilter>(); for (var evalValue = Start; evalValue <= End; evalValue++) { if (IsMatch(evalValue)) { filters.Add(new SpecificFilter(evalValue, Kind)); } } SpecificFilters = filters; }
/// <summary> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldKind kind, string expression) { return(TryParse(kind, expression, ErrorHandling.Throw).Value); }
private void JoinFilters(List<string> paramList, CrontabFieldKind kind) { paramList.Add( string.Join(",", Filters .Where(x => x.Key == kind) .SelectMany(x => x.Value.Select(y => y.ToString())).ToArray() ) ); }
private static int GetValue(ref string filter, CrontabFieldKind kind) { var maxValue = Constants.MaximumDateTimeValues[kind]; if (string.IsNullOrEmpty(filter)) throw new CrontabException("Expected number, but filter was empty."); int i, value; var isDigit = char.IsDigit(filter[0]); var isLetter = char.IsLetter(filter[0]); // Because this could either numbers, or letters, but not a combination, // check each condition separately. for (i = 0; i < filter.Length; i++) if ((isDigit && !char.IsDigit(filter[i])) || (isLetter && !char.IsLetter(filter[i]))) break; var valueToParse = filter.Substring(0, i); if (int.TryParse(valueToParse, out value)) { filter = filter.Substring(i); var returnValue = value; if (returnValue > maxValue) throw new CrontabException(string.Format("Value for {0} filter exceeded maximum value of {1}", Enum.GetName(typeof(CrontabFieldKind), kind), maxValue)); return returnValue; } else { List<KeyValuePair<string, int>> replaceVal = null; if (kind == CrontabFieldKind.DayOfWeek) replaceVal = Constants.Days.Where(x => valueToParse.StartsWith(x.Key)).ToList(); else if (kind == CrontabFieldKind.Month) replaceVal = Constants.Months.Where(x => valueToParse.StartsWith(x.Key)).ToList(); if (replaceVal != null && replaceVal.Count == 1) { // missingFilter addresses when a filter string of "SUNL" is passed in, // which causes the isDigit/isLetter loop above to iterate through the end // of the string. This catches the edge case, and re-appends L to the end. var missingFilter = ""; if (filter.Length == i && filter.EndsWith("L") && kind == CrontabFieldKind.DayOfWeek) missingFilter = "L"; filter = filter.Substring(i) + missingFilter; var returnValue = replaceVal.First().Value; if (returnValue > maxValue) throw new CrontabException(string.Format("Value for {0} filter exceeded maximum value of {1}", Enum.GetName(typeof(CrontabFieldKind), kind), maxValue)); return returnValue; } } throw new CrontabException("Filter does not contain expected number"); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="specificValue">The specific value you wish to match</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificFilter(int specificValue, CrontabFieldKind kind) { SpecificValue = specificValue; Kind = kind; }
/// <summary> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldKind kind, string expression) { return new CrontabField(CrontabFieldImpl.FromKind(kind), expression); }
public static ValueOrError<CrontabField> TryParse(CrontabFieldKind kind, string expression) { return TryParse(kind, expression, null); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="specificValue">The specific value you wish to match</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificYearFilter(int specificValue, CrontabFieldKind kind) : base (specificValue, kind) {}
private static List<SpecificFilter> GetSpecificFilters(Dictionary<CrontabFieldKind, List<ICronFilter>> filters, CrontabFieldKind kind) { return filters[kind].Where(x => x.GetType() == typeof(SpecificFilter)).Cast<SpecificFilter>().Union( filters[kind].Where(x => x.GetType() == typeof(RangeFilter)).SelectMany(x => ((RangeFilter)x).SpecificFilters) ).Union( filters[kind].Where(x => x.GetType() == typeof(StepFilter)).SelectMany(x => ((StepFilter)x).SpecificFilters) ).ToList(); }
private static ICronFilter _ParseFilter(string filter, CrontabFieldKind kind) { var newFilter = filter.ToUpper(); try { if (newFilter.StartsWith("*", StringComparison.OrdinalIgnoreCase)) { newFilter = newFilter.Substring(1); if (newFilter.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { newFilter = newFilter.Substring(1); var steps = _GetValue(ref newFilter, kind); return(new StepFilter(0, steps, kind)); } return(new AnyFilter(kind)); } // * * LW * * // * * L * * if (newFilter.StartsWith("L") && kind == CrontabFieldKind.Day) { newFilter = newFilter.Substring(1); if (newFilter == "W") { return(new LastWeekdayOfMonthFilter(kind)); } return(new LastDayOfMonthFilter(kind)); } if (newFilter == "?") { return(new BlankDayOfMonthOrWeekFilter(kind)); } var firstValue = _GetValue(ref newFilter, kind); if (string.IsNullOrEmpty(newFilter)) { if (kind == CrontabFieldKind.Year) { return(new SpecificYearFilter(firstValue, kind)); } return(new SpecificFilter(firstValue, kind)); } switch (newFilter[0]) { case '/': { newFilter = newFilter.Substring(1); var secondValue = _GetValue(ref newFilter, kind); return(new StepFilter(firstValue, secondValue, kind)); } case '-': { newFilter = newFilter.Substring(1); var secondValue = _GetValue(ref newFilter, kind); int?steps = null; if (newFilter.StartsWith("/")) { newFilter = newFilter.Substring(1); steps = _GetValue(ref newFilter, kind); } return(new RangeFilter(firstValue, secondValue, steps, kind)); } case '#': { newFilter = newFilter.Substring(1); var secondValue = _GetValue(ref newFilter, kind); if (!string.IsNullOrEmpty(newFilter)) { throw new CrontabException(string.Format("Invalid filter '{0}'", filter)); } return(new SpecificDayOfWeekInMonthFilter(firstValue, secondValue, kind)); } default: if (newFilter == "L" && kind == CrontabFieldKind.DayOfWeek) { return(new LastDayOfWeekInMonthFilter(firstValue, kind)); } else if (newFilter == "W" && kind == CrontabFieldKind.Day) { return(new NearestWeekdayFilter(firstValue, kind)); } break; } throw new CrontabException(string.Format("Invalid filter '{0}'", filter)); } catch (Exception e) { throw new CrontabException(string.Format("Invalid filter '{0}'. See inner exception for details.", filter), e); } }
private static int _GetValue(ref string filter, CrontabFieldKind kind) { var maxValue = Constants.MaximumDateTimeValues[kind]; if (string.IsNullOrEmpty(filter)) { throw new CrontabException("Expected number, but filter was empty."); } int i, value; var isDigit = char.IsDigit(filter[0]); var isLetter = char.IsLetter(filter[0]); // Because this could either numbers, or letters, but not a combination, // check each condition separately. for (i = 0; i < filter.Length; i++) { if (isDigit && !char.IsDigit(filter[i]) || isLetter && !char.IsLetter(filter[i])) { break; } } var valueToParse = filter.Substring(0, i); if (int.TryParse(valueToParse, out value)) { filter = filter.Substring(i); var returnValue = value; if (returnValue > maxValue) { throw new CrontabException($"Value for {Enum.GetName(typeof(CrontabFieldKind), kind)} filter exceeded maximum value of {maxValue}"); } return(returnValue); } List <KeyValuePair <string, int> > replaceVal = null; switch (kind) { case CrontabFieldKind.DayOfWeek: replaceVal = Constants.Days.Where(x => valueToParse.StartsWith(x.Key)).ToList(); break; case CrontabFieldKind.Month: replaceVal = Constants.Months.Where(x => valueToParse.StartsWith(x.Key)).ToList(); break; } if (replaceVal != null && replaceVal.Count == 1) { // missingFilter addresses when a filter string of "SUNL" is passed in, // which causes the isDigit/isLetter loop above to iterate through the end // of the string. This catches the edge case, and re-appends L to the end. var missingFilter = ""; if (filter.Length == i && filter.EndsWith("L") && kind == CrontabFieldKind.DayOfWeek) { missingFilter = "L"; } filter = filter.Substring(i) + missingFilter; var returnValue = replaceVal.First().Value; if (returnValue > maxValue) { throw new CrontabException($"Value for {Enum.GetName(typeof(CrontabFieldKind), kind)} filter exceeded maximum value of {maxValue}"); } return(returnValue); } throw new CrontabException("Filter does not contain expected number"); }
private static List<ICronFilter> ParseField(string field, CrontabFieldKind kind) { try { return field.Split(',').Select(filter => ParseFilter(filter, kind)).ToList(); } catch (Exception e) { throw new CrontabException(string.Format("There was an error parsing '{0}' for the {1} field", field, Enum.GetName(typeof(CrontabFieldKind), kind)), e); } }
public bool IsMatch(DateTime value, CrontabFieldKind kind) { return(Filters.Where(x => x.Key == kind).SelectMany(x => x.Value).Any(filter => filter.IsMatch(value))); }
private static ICronFilter ParseFilter(string filter, CrontabFieldKind kind) { var newFilter = filter.ToUpper(); try { if (newFilter.StartsWith("*", StringComparison.OrdinalIgnoreCase)) { newFilter = newFilter.Substring(1); if (newFilter.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { newFilter = newFilter.Substring(1); var steps = GetValue(ref newFilter, kind); return new StepFilter(0, steps, kind); } return new AnyFilter(kind); } // * * LW * * // * * L * * if (newFilter.StartsWith("L") && kind == CrontabFieldKind.Day) { newFilter = newFilter.Substring(1); if (newFilter == "W") return new LastWeekdayOfMonthFilter(kind); else return new LastDayOfMonthFilter(kind); } if (newFilter == "?") return new BlankDayOfMonthOrWeekFilter(kind); var firstValue = GetValue(ref newFilter, kind); if (string.IsNullOrEmpty(newFilter)) { if (kind == CrontabFieldKind.Year) return new SpecificYearFilter(firstValue, kind); else return new SpecificFilter(firstValue, kind); } switch (newFilter[0]) { case '/': { newFilter = newFilter.Substring(1); var secondValue = GetValue(ref newFilter, kind); return new StepFilter(firstValue, secondValue, kind); } case '-': { newFilter = newFilter.Substring(1); var secondValue = GetValue(ref newFilter, kind); int? steps = null; if (newFilter.StartsWith("/")) { newFilter = newFilter.Substring(1); steps = GetValue(ref newFilter, kind); } return new RangeFilter(firstValue, secondValue, steps, kind); } case '#': { newFilter = newFilter.Substring(1); var secondValue = GetValue(ref newFilter, kind); if (!string.IsNullOrEmpty(newFilter)) throw new CrontabException(string.Format("Invalid filter '{0}'", filter)); return new SpecificDayOfWeekInMonthFilter(firstValue, secondValue, kind); } default: if (newFilter == "L" && kind == CrontabFieldKind.DayOfWeek) { return new LastDayOfWeekInMonthFilter(firstValue, kind); } else if (newFilter == "W" && kind == CrontabFieldKind.Day) { return new NearestWeekdayFilter(firstValue, kind); } break; } throw new CrontabException(string.Format("Invalid filter '{0}'", filter)); } catch (Exception e) { throw new CrontabException(string.Format("Invalid filter '{0}'. See inner exception for details.", filter), e); } }
public static ValueOrError <CrontabField> TryParse(CrontabFieldKind kind, string expression) { return(TryParse(kind, expression, null)); }
public void BlankDayOfMonthOrWeekFilterInvalidState() { var values = new CrontabFieldKind[] { CrontabFieldKind.Hour, CrontabFieldKind.Minute, CrontabFieldKind.Month, CrontabFieldKind.Second, CrontabFieldKind.Year }; foreach (var val in values) Assert2.Throws<CrontabException>(() => new BlankDayOfMonthOrWeekFilter(val), "Ensure BlankDayOfMonthOrWeekFilter can't be instantiated with <{0}>", Enum.GetName(typeof(CrontabFieldKind), val)); Assert.IsTrue(new BlankDayOfMonthOrWeekFilter(CrontabFieldKind.Day).IsMatch(DateTime.Now)); Assert.IsTrue(new BlankDayOfMonthOrWeekFilter(CrontabFieldKind.DayOfWeek).IsMatch(DateTime.UtcNow)); }
public bool IsMatch(DateTime value, CrontabFieldKind kind) { return Filters.Where(x => x.Key == kind).SelectMany(x => x.Value).Any(filter => filter.IsMatch(value)); }
/// <summary> /// Constructs a new RangeFilter instance /// </summary> /// <param name="specificValue">The specific value you wish to match</param> /// <param name="kind">The crontab field kind to associate with this filter</param> public SpecificYearFilter(int specificValue, CrontabFieldKind kind) : base(specificValue, kind) { }
public static ValueOrError<CrontabField> TryParse(CrontabFieldKind kind, string expression, ExceptionHandler onError) { var field = new CrontabField(CrontabFieldImpl.FromKind(kind)); var error = field._impl.TryParse(expression, field.Accumulate, onError); return error == null ? field : (ValueOrError<CrontabField>)error; }
/// <summary> /// Constructs a new AnyFilter instance /// </summary> /// <param name="kind">The crontab field kind to associate with this filter</param> public AnyFilter(CrontabFieldKind kind) { Kind = kind; }
/// <summary> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldKind kind, string expression) => TryParse(kind, expression, v => v, e => { throw e(); });
/// <summary> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldKind kind, string expression) { return TryParse(kind, expression, ErrorHandling.Throw).Value; }
public static CrontabField TryParse(CrontabFieldKind kind, string expression) => TryParse(kind, expression, v => v, _ => null);
/// <summary> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldKind kind, string expression) { return(new CrontabField(CrontabFieldImpl.FromKind(kind), expression)); }