

Private Dictionary _outstandingChars = new Dictionary() Private readonly Dictionary _chars = new Dictionary() In such situation algorithm doesn’t need to filter out the random pool as that stage any character is valid. Second route (inside else block) is situation where number of chars still to be generated is greater than number of outstanding items in _outstandingChars object. A result is being appended to password object. First route calls DrawChar function with argument which is an array of outstanding types. Such decision is being made on each iteration validating with current state of outstanding chars. Scope of search has to be narrowed down just to uppercases and digits. It’s easy to describe on an example: if expected password length is 4, minimum number of uppercases is 2 and minimum number of digits is 2, then we cannot look for character within all types. First one takes place when number of outstanding items equals to number of outstanding chars to be drawn. Within for’s body there are two possible routes. In the other words, every loop iteration draws one character. After that a for loop is started which does the same number of iterations as it is set in Length property. Then ResetOutstanding is called which has been described above and new StringBuilder object is instantiated. If it’s not then argument exception is being thrown. At the beginning it checks whether configured properties are valid, which means whether expected string length is greater than or equal to sum of minimum number of lowercases, uppercases, digits and specials. In opposite to previous ones, it’s public and it’s the one which returns fully generated password.

Last part of our class is Generate function.
