public void LoadGenerator(RandomStringGenerator Generator) { textBoxName.Text = Generator.Name; comboBoxEncoding.SelectedIndex = GeneratorEncoding.ReturnEncodingIndex(Generator.Encoding); numericUpDownNumberOfStrings.Value = Convert.ToInt32(Generator.MaximumStrings); numericUpDownStringLength.Value = Convert.ToDecimal(Generator.StringLength); checkBoxAllowRepetitions.Checked = Generator.AllowRepetitions; textBoxCharacterSet.Text = Generator.CharacterSet; }
public RandomStringGenerator GetGenerator() { RandomStringGenerator randomGenerator = new RandomStringGenerator(); randomGenerator.Name = textBoxName.Text; randomGenerator.Encoding = GeneratorEncoding.GetEncoding(comboBoxEncoding.SelectedIndex); randomGenerator.CharacterSet = textBoxCharacterSet.Text; randomGenerator.StringLength = Convert.ToInt32(numericUpDownStringLength.Value); randomGenerator.MaximumStrings = Convert.ToInt32(numericUpDownNumberOfStrings.Value); randomGenerator.AllowRepetitions = checkBoxAllowRepetitions.Checked; return randomGenerator; }
private List<string> BuildRandomStrings(RandomStringGenerator Generator, string Text) { List<string> Fuzzed = new List<string>(); string finaltext = string.Empty; for (int iRows = 1; iRows <= Generator.MaximumStrings; iRows++) { char zuletzt = '*'; List<Char> UsedChars = new List<char>(); for (int iChar = 0; iChar < Generator.StringLength; iChar++) { Random zahl = new Random(); Char NeuBuchstabe = Generator.CharacterSet[zahl.Next(0, Generator.CharacterSet.Length - 1)]; if (!Generator.AllowRepetitions) if (UsedChars.Contains(NeuBuchstabe)) { iChar--; continue; } finaltext += NeuBuchstabe.ToString(); zuletzt = NeuBuchstabe; UsedChars.Add(zuletzt); } Fuzzed.Add(Text.Replace("{" + Generator.Name + "}", finaltext)); } return new List<string>(); }