private static int getUnusedPosition(this RandomString str, AlphanumericFormat format) { do { var i = str.RandomNumber(0, str._size); if (str.checkPositions(i)) { return(i); } } while (true); }
public static void UpdateFormat(this RandomString str, AlphanumericFormat format, bool included) { var has = str._positions.ContainsKey(format); if (included && !has) { str._positions.Add(format, 0); } if (!included && has) { str._positions.Remove(format); } str.handleSize(); }
private static void generateChar(this RandomString str, AlphanumericFormat format, int position, int byteBuffer) { if (format != AlphanumericFormat.NonAlphanumeric) { str._buff[position] = (char)(format + byteBuffer); } else { str._buff[position] = str._specialChars[byteBuffer]; } str._positions[format] = position; }
private static void rngChar(this RandomString str, AlphanumericFormat format, int position) { var byteBuffer = 0; switch (format) { case AlphanumericFormat.Numeric: byteBuffer = str.RandomNumber(0, 9); break; case AlphanumericFormat.Lowercase: case AlphanumericFormat.Uppercase: byteBuffer = str.RandomNumber(0, 26); break; default: byteBuffer = str.RandomNumber(0, str._specialChars.Length); break; } str.generateChar(format, position, byteBuffer); }