public static T Enum <T>(this System.Random random) where T : Enum { var values = System.Enum.GetValues(typeof(T)).OfType <object>().ToList(); var value = random.Element(values); return((T)value); }
/// <summary>Organises the specified collection into multiple smaller collections of variable size.</summary> public static IEnumerable <IEnumerable <T> > Chunks <T>(this System.Random random, IEnumerable <T> source, int count) { var chunks = Enumerable.Range(0, count).Select(_ => new List <T>()).ToList(); foreach (var element in source) { random.Element(chunks).Add(element); } return(chunks); }
public static string Words(this System.Random random, int count) { var words = Enumerable.Range(0, count).Select(_ => random.Element(Data.Words)); return(string.Join(" ", words)); }
public static string Word(this System.Random random) => random.Element(Data.Words);
public static string Sentence(this System.Random random) => random.Element(Data.Sentences);
public static string Company(this System.Random random) => random.Element(Data.Companies);
public static string Street(this System.Random random) => random.Element(Data.Streets);
public static string Surname(this System.Random random) => random.Element(Data.Surnames);
public static string Forename(this System.Random random) => Boolean(random) ? random.Element(Data.FemaleNames) : random.Element(Data.MaleNames);
public static string FemaleForename(this System.Random random) => random.Element(Data.FemaleNames);
public static string City(this System.Random random) => random.Element(Data.Cities);