/// <summary>
 ///  Constructs the non-fixed-length numbering rules with the specified options.
 /// </summary>
 /// <param name="options">
 ///  The options for the rule. Must contain <see cref="NumberingOptions.Alpha"/> and/or
 ///  <see cref="NumberingOptions.Numeric"/>.
 /// </param>
 ///
 /// <exception cref="ArgumentException">
 ///  <paramref name="options"/> contains <see cref="NumberingOptions.FixedLength"/> or does not contain
 ///  <see cref="NumberingOptions.Alpha"/> and/or <see cref="NumberingOptions.Numeric"/>.
 /// </exception>
 public NumberingRule(NumberingOptions options)
 {
     if (options.HasFlag(NumberingOptions.FixedLength))
     {
         throw new ArgumentException("Must construct FixedLength NumberingRule with fixedLength parameter!");
     }
     if ((options & NumberingOptions.AlphaNumeric) == 0)
     {
         throw new ArgumentException("Numbering Options must be alpha and/or numeric!");
     }
     Options     = options;
     FixedLength = -1;
     Base        = CalculateBase(options);
 }
 /// <summary>
 /// Constructs the fixed-length numbering rules with the specified options.
 /// </summary>
 /// <param name="options">
 ///  The options for the rule. Must contain <see cref="NumberingOptions.Alpha"/> and or
 ///  <see cref="NumberingOptions.Numeric"/>. <see cref="NumberingOptions.FixedLength"/> is automatically added.
 /// </param>
 /// <param name="fixedLength">The fixed length that must be greater than zero.</param>
 ///
 /// <exception cref="ArgumentException">
 ///  <paramref name="options"/> does not contain <see cref="NumberingOptions.Alpha"/> and/or
 ///  <seecref="NumberingOptions.Numeric"/>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///  <paramref name="fixedLength"/> is less than one.
 /// </exception>
 public NumberingRule(NumberingOptions options, int fixedLength)
 {
     if ((options & NumberingOptions.AlphaNumeric) == 0)
     {
         throw new ArgumentException("Numbering Options must be alpha and/or numeric!");
     }
     if (fixedLength < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(fixedLength));
     }
     Options     = options | NumberingOptions.FixedLength;
     FixedLength = fixedLength;
     Base        = CalculateBase(options);
 }
        /// <summary>
        ///  Calculates the base of the numbering rule.
        /// </summary>
        /// <param name="options">The options used to calulcate the base.</param>
        /// <returns>The calculated base of the rule.</returns>
        private static int CalculateBase(NumberingOptions options)
        {
            int zeroIndexed = (options.HasFlag(NumberingOptions.ZeroIndexed) ? 0 : 1);

            switch (options & NumberingOptions.AlphaNumeric)
            {
            case NumberingOptions.Numeric:          return(10 - zeroIndexed);

            case NumberingOptions.Alpha:            return(26 - zeroIndexed + PostAlphaDigits.Length);

            case NumberingOptions.AlphaNumeric:     return(36 - zeroIndexed + PostAlphaDigits.Length);

            default: return(0);
            }
        }