示例#1
0
        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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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));
        }
示例#4
0
 public static string Word(this System.Random random) => random.Element(Data.Words);
示例#5
0
 public static string Sentence(this System.Random random) => random.Element(Data.Sentences);
示例#6
0
 public static string Company(this System.Random random) => random.Element(Data.Companies);
示例#7
0
 public static string Street(this System.Random random) => random.Element(Data.Streets);
示例#8
0
 public static string Surname(this System.Random random) => random.Element(Data.Surnames);
示例#9
0
 public static string Forename(this System.Random random) =>
 Boolean(random) ? random.Element(Data.FemaleNames) : random.Element(Data.MaleNames);
示例#10
0
 public static string FemaleForename(this System.Random random) => random.Element(Data.FemaleNames);
示例#11
0
 public static string City(this System.Random random) => random.Element(Data.Cities);