public static Name Gen(bool allowDuplicates, bool firstNameOnly) { string fName, lName; bool isUnique = true; long dupCounter = 0; do { //Generate first Name fName = _firstNames[random.Next(0, _firstNames.Count)]; //Generate last Name lName = _lastNames[random.Next(0, _lastNames.Count)]; //Enforce Uniqueness. isUnique = !filter.CheckFor(fName + lName); if (!isUnique) { dupCounter++; } if (dupCounter >= (CALC_CONSTANT ^ 2)) { throw new Exception("Out of combinations..."); } } while (!isUnique); //Add to used names filter.AddItem(fName + lName); //Return new Name Object => See class for more info... return(new Name(fName, lName)); }
/// <summary> /// Generates a DID, Given the dept name /// </summary> /// <param name="deptName"></param> /// <returns></returns> public static string DID(string deptName, string STRID) { var id = "Dpt" + ( Convert.ToBase64String( hasher.ComputeHash( Encoding.ASCII.GetBytes(deptName + STRID))).Substring(0, 20) + Convert.ToBase64String( Encoding.ASCII.GetBytes(deptName))).Substring(0, 10); if (!filter.CheckFor(id)) { filter.AddItem(id); } return(id.Replace("/", "c").Replace("=", "b").Replace("+", "A").Replace("\\", "C")); }
public static Address GenAddress() { var street = RoadNames[random.Next(RoadNames.Count)] + " " + Prefixes[random.Next(Prefixes.Count)]; var address = new Address(street, GenRegion()); if (usedAddr.CheckFor(address)) { //If it exists return(GenAddress()); // Gen a new addr } else { return(address); } }
public static Address GenAddress() { if (usedAddr == null) { usedAddr = new BloomFilter("Addresses"); Logger.LogG("Created Filter."); } var street = RoadNames[random.Next(RoadNames.Count)] + " " + Prefixes[random.Next(Prefixes.Count)]; var address = new Address(street, GenRegion()); if (usedAddr.CheckFor(address)) { //If it exists return(GenAddress()); // Gen a new addr } else { return(address); } }