private RandomPassword Clone() { var clone = new RandomPassword(this.maxLength, this.usableCharacters); clone.characterShuoldHaveOverThreeKinds = this.characterShuoldHaveOverThreeKinds; clone.characterShuoldNotDuplicate = this.characterShuoldNotDuplicate; clone.similarCharacterExist = this.similarCharacterExist; clone.notStartWithExcelSpecialCharacter = this.notStartWithExcelSpecialCharacter; return(clone); }
public RandomPasswordWithRuby GeneratePassword() { while (true) { string candidate = generatePasswordCandidate(); if (this.characterShuoldHaveOverThreeKinds && RandomPassword.CalculateCharacterKindCount(candidate) < 3) { continue; } if (this.characterShuoldNotDuplicate && candidate.Distinct().Count() != candidate.ToArray().Count()) { continue; } if (this.notStartWithExcelSpecialCharacter && RandomPassword.ExcelSpecialCharacters.Any(x => candidate.StartsWith(x))) { continue; } return(new RandomPasswordWithRuby(candidate)); } }