private static char Character(CharacterSet characterSet) { string characters = ""; if (characterSet.HasFlag(CharacterSet.Alphabetic)) { characters += Alphabet; } if (characterSet.HasFlag(CharacterSet.Numeric)) { characters += Numeric; } if (characterSet.HasFlag(CharacterSet.ExtraCharacters)) { characters += ExtraCharacters; } if (characters.Length == 0) { throw new ArgumentOutOfRangeException("characterSet"); } return(characters[Random.Next(0, characters.Length)]); }
private static char Character(CharacterSet characterSet) { string characters = ""; if( characterSet.HasFlag( CharacterSet.Alphabetic ) ) characters += Alphabet; if( characterSet.HasFlag( CharacterSet.Numeric ) ) characters += Numeric; if( characterSet.HasFlag( CharacterSet.ExtraCharacters ) ) characters += ExtraCharacters; if (characters.Length == 0) throw new ArgumentOutOfRangeException("characterSet"); return characters[Random.Next(0, characters.Length)]; }
private static string BuildCharacterSet(CharacterSet set) { var characterSetValues = Enum.GetValues(typeof(CharacterSet)); string result = ""; foreach (CharacterSet value in characterSetValues) { if (set.HasFlag(value)) { switch (value) { case CharacterSet.BasicSet: result += BasicSet; break; case CharacterSet.FrenchQuotes: result += FrenchQuotes; break; case CharacterSet.SpanishQuestEx: result += SpanishQestEx; break; case CharacterSet.CyrillicSet: result += CyrillicSet; break; case CharacterSet.ExtendedLatin: result += ExtendedLatin; break; case CharacterSet.GreekAlphabet: result += GreekAlphabet; break; case CharacterSet.TurkishI: result += TurkishI; break; case CharacterSet.HebrewAlphabet: result += HebrewAlphabet; break; case CharacterSet.ArabicAlphabet: result += ArabicAlphabet; break; case CharacterSet.ThaiKhmerAlphabet: result += ThaiKhmerAlphabet; break; case CharacterSet.Hiragana: result += Hiragana; break; case CharacterSet.JapDigits: result += JapDigits; break; case CharacterSet.AsianQuotes: result += AsianQuotes; break; case CharacterSet.EssentialKanji: result += EssentialKanji; break; case CharacterSet.Katakana: result += Katakana; break; } } } var hset = new HashSet <char>(); foreach (var c in result) { hset.Add(c); } result = new string(hset.ToArray()); return(result); }
private static string BuildCharacterSet(CharacterSet set) { var characterSetValues = Enum.GetValues(typeof(CharacterSet)); string result = ""; foreach (CharacterSet value in characterSetValues) { if (set.HasFlag(value)) { switch (value) { case CharacterSet.BasicSet: result += BasicSet; break; case CharacterSet.FrenchQuotes: result += FrenchQuotes; break; case CharacterSet.SpanishQuestEx: result += SpanishQestEx; break; case CharacterSet.CyrillicSet: result += CyrillicSet; break; case CharacterSet.ExtendedLatin: result += ExtendedLatin; break; case CharacterSet.GreekAlphabet: result += GreekAlphabet; break; case CharacterSet.TurkishI: result += TurkishI; break; case CharacterSet.HebrewAlphabet: result += HebrewAlphabet; break; case CharacterSet.ArabicAlphabet: result += ArabicAlphabet; break; case CharacterSet.ThaiKhmerAlphabet: result += ThaiKhmerAlphabet; break; case CharacterSet.Hiragana: result += Hiragana; break; case CharacterSet.JapDigits: result += JapDigits; break; case CharacterSet.AsianQuotes: result += AsianQuotes; break; case CharacterSet.EssentialKanji: result += EssentialKanji; break; case CharacterSet.Katakana: result += Katakana; break; } } } var hset = new HashSet<char>(); foreach (var c in result) { hset.Add(c); } result = new string(hset.ToArray()); return result; }
private static string BuildCharacterSet(CharacterSet set) { var characterSetValues = Enum.GetValues(typeof(CharacterSet)); var result = ""; foreach (CharacterSet value in characterSetValues) { if (!set.HasFlag(value)) { continue; } switch (value) { case CharacterSet.BasicSet: result += BASIC_SET; break; case CharacterSet.FrenchQuotes: result += FRENCH_QUOTES; break; case CharacterSet.SpanishQuestEx: result += SPANISH_QEST_EX; break; case CharacterSet.CyrillicSet: result += CYRILLIC_SET; break; case CharacterSet.ExtendedLatin: result += EXTENDED_LATIN; break; case CharacterSet.GreekAlphabet: result += GREEK_ALPHABET; break; case CharacterSet.TurkishI: result += TURKISH_I; break; case CharacterSet.HebrewAlphabet: result += HEBREW_ALPHABET; break; case CharacterSet.ArabicAlphabet: result += ARABIC_ALPHABET; break; case CharacterSet.ThaiKhmerAlphabet: result += THAI_KHMER_ALPHABET; break; case CharacterSet.Hiragana: result += HIRAGANA; break; case CharacterSet.JapDigits: result += JAP_DIGITS; break; case CharacterSet.AsianQuotes: result += ASIAN_QUOTES; break; case CharacterSet.EssentialKanji: result += ESSENTIAL_KANJI; break; case CharacterSet.Katakana: result += KATAKANA; break; } } var hset = new HashSet <char>(); foreach (var c in result) { hset.Add(c); } result = new string(hset.ToArray()); return(result); }