public static CrontabFieldImpl FromKind(CrontabFieldType kind) { if (!Enum.IsDefined(typeof(CrontabFieldType), kind)) { throw new ArgumentException(string.Format( "Invalid crontab field kind. Valid values are {0}.", string.Join(", ", Enum.GetNames(typeof(CrontabFieldType)))), nameof(kind)); } return(FieldByKind[(int)kind]); }
private CrontabFieldImpl(CrontabFieldType kind, int minValue, int maxValue, string[] names) { Debug.Assert(Enum.IsDefined(typeof(CrontabFieldType), 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> /// Parses a crontab field expression given its kind. /// </summary> public static CrontabField Parse(CrontabFieldType kind, string expression) { return(new CrontabField(CrontabFieldImpl.FromKind(kind), expression)); }