protected void CheckConfiguration(CodeGeneratorConfigurationBase configuration) { var allowedChars = new AllowedCharactersBuilder().BuildFromConfiguration(configuration.AllowedCharacters); if (allowedChars == null || allowedChars.Length == 0) { throw new ConfigurationErrorsException("No allowed chars. Configuration resolves to empty list."); } if (configuration.CodeLength <= 0) { throw new ConfigurationErrorsException("Not allowed code length. Code length must be greater then zero."); } }
public static char[] BuildFromConfiguration(this AllowedCharactersBuilder builder, AllowedCharactersBuilderConfiguration configuration) { if (configuration.AllowNumeric) { builder.AddNumeric(); } if (configuration.AllowUpperAlphabet) { builder.AddUpperAlphabet(); } if (configuration.AllowLowerAlphabet) { builder.AddLowerAlphabet(); } if (configuration.AllowSpecialChars) { builder.AddSpecialChars(); } return(builder.Build()); }