コード例 #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);