Beispiel #1
0
        private static int ProcessData(string[] data, string validatorFunction)
        {
            int total = 0;

            for (int i = 0; i < data.Length; i++)
            {
                string     raw        = data[i];
                RuleParser ruleParser = new RuleParser();
                ruleParser.ParseRules(raw.Substring(0, raw.IndexOf(':')));
                PasswordValidator passValidator = new PasswordValidator(
                    ruleParser,
                    raw.Substring(raw.IndexOf(':'))
                    );
                if (validatorFunction == "part1" && passValidator.IsPart1Valid())
                {
                    total += 1;
                }
                else if (validatorFunction == "part2" && passValidator.IsPart2Valid())
                {
                    total += 1;
                }
            }
            return(total);
        }
 public PasswordValidator(RuleParser rules, string password)
 {
     Rules    = rules;
     Password = password;
 }