public static T SelectOne <T>(this IRng rng) where T : Enum { var values = _enumValues.GetOrAdd(typeof(T), k => Enum.GetValues(k)); var selection = rng.GetInt32(0, values.Length - 1); return((T)values.GetValue(selection)); }
public static int GetInt32(this IRng rng, int minInclusive, int maxInclusive) { var range = Math.Abs(maxInclusive - minInclusive); var i = rng.GetInt32(range); return(i + minInclusive); }
public static int GetInt32(this IRng rng, int maxInclusive) { var i = rng.GetInt32(); var r = i % (maxInclusive + 1); if (r < 0) { r *= -1; } return(r); }
public static T SelectOne <T>(this IRng rng, T[] possibilities) { var selection = rng.GetInt32(0, possibilities.Length - 1); return(possibilities[selection]); }
public static decimal GetDecimal(this IRng rng) => new decimal(rng.GetInt32(), rng.GetInt32(), rng.GetInt32(), rng.GetBit(), 2);