Beispiel #1
0
        public static int GetDefaultPasswordLength()
        {
            int length = Constants.DefaultPasswordLength;

            RuleSetConfig config = GetDefaultRuleSetConfig();

            if (config != null)
            {
                length = config.PasswordLength;
            }

            return(length);
        }
Beispiel #2
0
        public static RuleSet GetDefaultRuleSet()
        {
            RuleSet ruleSet = RuleSet.Default;

            RuleSetConfig config = GetDefaultRuleSetConfig();

            if (config != null)
            {
                IEnumerable <CharacterSetRequirement> requirements = RuleSetConfig.DefaultRuleSetConfig.Requirements
                                                                     .All
                                                                     .Select(
                    r => new CharacterSetRequirement(new CharacterSet(r.Name, r.CharacterArray), r.MinCount));

                ruleSet = new RuleSet(requirements);
            }

            return(ruleSet);
        }
Beispiel #3
0
        private static RuleSetConfig GetDefaultRuleSetConfig()
        {
            RuleSetConfig config = null;

            try
            {
                config = RuleSetConfig.DefaultRuleSetConfig;
            }
            catch (Exception ex)
            {
                var previousColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine(ex.Message);
                Console.ForegroundColor = previousColor;

                config = null;
            }

            return(config);
        }