/// <summary> /// Randomly generates a list of values of the specified enum type /// </summary> /// <typeparam name="T">Type to the be generated</typeparam> /// <param name="Random">Random object</param> /// <param name="Amount">Number of items to generate</param> /// <param name="Generator"> /// Generator to be used (if not included, default generator is used) /// </param> /// <returns>The randomly generated value</returns> public static IEnumerable <T> NextEnum <T>(this System.Random Random, int Amount, IGenerator <T> Generator = null) { Contract.Requires <ArgumentNullException>(Random != null, "Random"); SetupGenerators(); Generator = Generator.Check(new EnumGenerator <T>()); return(Amount.Times(x => Generator.Next(Random))); }
/// <summary> /// Randomly generates a value of the specified enum type /// </summary> /// <typeparam name="T">Type to generate</typeparam> /// <param name="Random">Random object</param> /// <param name="Generator"> /// Generator to be used (if not included, default generator is used) /// </param> /// <returns>The randomly generated value</returns> public static T NextEnum <T>(this System.Random Random, IGenerator <T> Generator = null) { Contract.Requires <ArgumentNullException>(Random != null, "Random"); SetupGenerators(); Generator = Generator.Check(new EnumGenerator <T>()); return(Generator.Next(Random)); }