コード例 #1
0
 public void TearDown()
 {
     cut = null;
 }
コード例 #2
0
        /// <summary>
        /// Parses the specified month value specification into a cron effective value.
        /// </summary>
        /// <param name="lowerLimit">
        /// The lower acceptable limit for values of this type.
        /// </param>
        /// <param name="upperLimit">
        /// The upper acceptable limit for values of this type.
        /// </param>
        /// <param name="names">
        /// An array of names associated with the numeric values. May be null.
        /// </param>
        /// <param name="valueSpec">
        /// The value specification to be parsed.
        /// </param>
        /// <returns>
        /// A cron effective value that matches the parsed value specification.
        /// </returns>
        private static CronEffectiveValue ParseMonthCronValue(int lowerLimit,
                                                              int upperLimit,
                                                              string[] names,
                                                              string valueSpec)
        {
            CronEffectiveValue cronValue = null;
            // The matcher to use
            Match m = null;

            if (valueSpec == null)
            {
                throw new System.ArgumentNullException("valueSpec");
            }

            if (WILDCARD_PATTERN.Equals(valueSpec))
            {
                // This is a wildcard specification (*)
                cronValue = new WildcardCronValue(lowerLimit, upperLimit, names);
            }
            else if ((m = MONTH_SINGLE_VALUE_PATTERN.Match(valueSpec)).Success)
            {
                // This is a single value specification (just an integer)
                int monthNumber = GetMonth(m.Groups[1].Value);
                cronValue = new SingleValueCronValue(lowerLimit, upperLimit, names, monthNumber);
            }
            else if ((m = MONTH_RANGE_PATTERN.Match(valueSpec)).Success)
            {
                // This is a range value specification (e.g. 5-10)
                int rangeLower = GetMonth(m.Groups[1].Value);
                int rangeUpper = GetMonth(m.Groups[2].Value);
                cronValue = new RangeCronValue(lowerLimit, upperLimit, names, rangeLower, rangeUpper);
            }
            else if ((m = STEP_PATTERN.Match(valueSpec)).Success)
            {
                // This is a step pattern (e.g. */3 - every third time period
                try
                {
                    int stepValue = int.Parse(m.Groups[1].Value);
                    cronValue = new StepCronValue(lowerLimit, upperLimit, names, stepValue);
                }
                catch (System.FormatException e)
                {
                    throw new System.ArgumentException(e.Message, "valueSpec");
                }
            }
            else
            {
                // Unrecognized value pattern
                throw new System.ArgumentException("Invalid value", "valueSpec");
            }

            return cronValue;
        }
コード例 #3
0
 public void SetUp()
 {
     cut = new SingleValueCronValue(0, 31, null, GOOD_TEST_VALUE);
 }