RandomProviderExtensions

Ecng.Common

The whole random vocabulary, asked of a source that can be handed around.

Methods

GetBool
public static bool GetBool(IRandomProvider provider)
result = RandomProviderExtensions.GetBool(provider)

Returns true or false.

provider
Source.

Returns: A bool.

GetByte
public static byte GetByte(IRandomProvider provider, byte min, byte max)
result = RandomProviderExtensions.GetByte(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A byte.

GetByte
public static byte GetByte(IRandomProvider provider, byte max)
result = RandomProviderExtensions.GetByte(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: A byte.

GetByte
public static byte GetByte(IRandomProvider provider)
result = RandomProviderExtensions.GetByte(provider)

Returns any byte.

provider
Source.

Returns: A byte.

GetBytes
public static byte[] GetBytes(IRandomProvider provider, int count)
result = RandomProviderExtensions.GetBytes(provider, count)

Returns random bytes.

provider
Source.
count
How many.

Returns: The bytes.

GetBytes
public static void GetBytes(IRandomProvider provider, byte[] buffer)
RandomProviderExtensions.GetBytes(provider, buffer)

Fills the buffer with random bytes.

provider
Source.
buffer
Buffer to fill.
GetDate
public static DateTime GetDate(IRandomProvider provider, DateTime min, DateTime max)
result = RandomProviderExtensions.GetDate(provider, min, max)

Returns a moment in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A DateTime.

GetDate
public static DateTime GetDate(IRandomProvider provider)
result = RandomProviderExtensions.GetDate(provider)

Returns any moment.

provider
Source.

Returns: A DateTime.

GetDecimal
public static decimal GetDecimal(IRandomProvider provider, int integer, int fractional)
result = RandomProviderExtensions.GetDecimal(provider, integer, fractional)

Returns a value with the stated number of digits either side of the point, never zero.

provider
Source.
integer
Most digits before the point.
fractional
Most digits after it.

Returns: A decimal.

GetDecimal
public static decimal GetDecimal(IRandomProvider provider, decimal min, decimal max, int precision)
result = RandomProviderExtensions.GetDecimal(provider, min, max, precision)

Returns a value in the range, rounded to the given number of decimals.

provider
Source.
min
Lower bound.
max
Upper bound.
precision
Decimal places to keep.

Returns: A decimal.

GetDouble
public static double GetDouble(IRandomProvider provider)
result = RandomProviderExtensions.GetDouble(provider)

Returns a value in [0, 1).

provider
Source.

Returns: A double.

GetDouble
public static double GetDouble(IRandomProvider provider, double max)
result = RandomProviderExtensions.GetDouble(provider, max)

Returns a value between zero and the bound.

provider
Source.
max
Upper bound.

Returns: A double.

GetDouble
public static double GetDouble(IRandomProvider provider, double min, double max)
result = RandomProviderExtensions.GetDouble(provider, min, max)

Returns a value in the range.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A double.

GetElement``1
public static T GetElement<T>(IRandomProvider provider, IEnumerable<T> values)
result = RandomProviderExtensions.GetElement(provider, values)

Returns one of the elements.

provider
Source.
values
The elements to choose from.

Returns: One of .

GetElement``1
public static T GetElement<T>(IRandomProvider provider, IList<T> values)
result = RandomProviderExtensions.GetElement(provider, values)

Returns one of the elements.

provider
Source.
values
The elements to choose from.

Returns: One of .

GetEnum
public static object GetEnum(IRandomProvider provider, Type enumType)
result = RandomProviderExtensions.GetEnum(provider, enumType)

Returns one of the values of an enum.

provider
Source.
enumType
Enum type.

Returns: A value of .

GetEnum``1
public static T GetEnum<T>(IRandomProvider provider, T min, T max)
result = RandomProviderExtensions.GetEnum(provider, min, max)

Returns an enum value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A value of .

GetEnum``1
public static T GetEnum<T>(IRandomProvider provider, IEnumerable<T> values)
result = RandomProviderExtensions.GetEnum(provider, values)

Returns one of the given enum values.

provider
Source.
values
The values to choose from.

Returns: One of .

GetEnum``1
public static T GetEnum<T>(IRandomProvider provider)
result = RandomProviderExtensions.GetEnum(provider)

Returns one of the values of an enum.

provider
Source.

Returns: A value of .

GetFloat
public static float GetFloat(IRandomProvider provider, float max)
result = RandomProviderExtensions.GetFloat(provider, max)

Returns a value between zero and the bound.

provider
Source.
max
Upper bound.

Returns: A float.

GetFloat
public static float GetFloat(IRandomProvider provider)
result = RandomProviderExtensions.GetFloat(provider)

Returns a value in [0, 1).

provider
Source.

Returns: A float.

GetFloat
public static float GetFloat(IRandomProvider provider, float min, float max)
result = RandomProviderExtensions.GetFloat(provider, min, max)

Returns a value in the range.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A float.

GetInt
public static int GetInt(IRandomProvider provider, int min, int max)
result = RandomProviderExtensions.GetInt(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: An int.

GetInt
public static int GetInt(IRandomProvider provider, int max)
result = RandomProviderExtensions.GetInt(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: An int.

GetInt
public static int GetInt(IRandomProvider provider)
result = RandomProviderExtensions.GetInt(provider)

Returns a value that is not negative.

provider
Source.

Returns: An int.

GetLong
public static long GetLong(IRandomProvider provider)
result = RandomProviderExtensions.GetLong(provider)

Returns any long.

provider
Source.

Returns: A long.

GetLong
public static long GetLong(IRandomProvider provider, long min, long max)
result = RandomProviderExtensions.GetLong(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A long.

GetSByte
public static sbyte GetSByte(IRandomProvider provider)
result = RandomProviderExtensions.GetSByte(provider)

Returns any sbyte.

provider
Source.

Returns: An sbyte.

GetSByte
public static sbyte GetSByte(IRandomProvider provider, sbyte max)
result = RandomProviderExtensions.GetSByte(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: An sbyte.

GetSByte
public static sbyte GetSByte(IRandomProvider provider, sbyte min, sbyte max)
result = RandomProviderExtensions.GetSByte(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: An sbyte.

GetShort
public static short GetShort(IRandomProvider provider, short min, short max)
result = RandomProviderExtensions.GetShort(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A short.

GetShort
public static short GetShort(IRandomProvider provider, short max)
result = RandomProviderExtensions.GetShort(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: A short.

GetShort
public static short GetShort(IRandomProvider provider)
result = RandomProviderExtensions.GetShort(provider)

Returns any short.

provider
Source.

Returns: A short.

GetString
public static string GetString(IRandomProvider provider, int min, int max)
result = RandomProviderExtensions.GetString(provider, min, max)

Returns a string of random characters.

provider
Source.
min
Shortest length.
max
Longest length.

Returns: A string.

GetTime
public static TimeSpan GetTime(IRandomProvider provider, TimeSpan min, TimeSpan max)
result = RandomProviderExtensions.GetTime(provider, min, max)

Returns a span in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A TimeSpan.

GetTime
public static TimeSpan GetTime(IRandomProvider provider)
result = RandomProviderExtensions.GetTime(provider)

Returns any span.

provider
Source.

Returns: A TimeSpan.

GetUInt
public static uint GetUInt(IRandomProvider provider)
result = RandomProviderExtensions.GetUInt(provider)

Returns any uint.

provider
Source.

Returns: A uint.

GetUInt
public static uint GetUInt(IRandomProvider provider, uint min, uint max)
result = RandomProviderExtensions.GetUInt(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A uint.

GetUInt
public static uint GetUInt(IRandomProvider provider, uint max)
result = RandomProviderExtensions.GetUInt(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: A uint.

GetULong
public static ulong GetULong(IRandomProvider provider, ulong min, ulong max)
result = RandomProviderExtensions.GetULong(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A ulong.

GetULong
public static ulong GetULong(IRandomProvider provider, ulong max)
result = RandomProviderExtensions.GetULong(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: A ulong.

GetULong
public static ulong GetULong(IRandomProvider provider)
result = RandomProviderExtensions.GetULong(provider)

Returns any ulong.

provider
Source.

Returns: A ulong.

GetUShort
public static ushort GetUShort(IRandomProvider provider, ushort max)
result = RandomProviderExtensions.GetUShort(provider, max)

Returns a value between zero and the bound, both ends included.

provider
Source.
max
Upper bound.

Returns: A ushort.

GetUShort
public static ushort GetUShort(IRandomProvider provider, ushort min, ushort max)
result = RandomProviderExtensions.GetUShort(provider, min, max)

Returns a value in the range, both ends included.

provider
Source.
min
Lower bound.
max
Upper bound.

Returns: A ushort.

GetUShort
public static ushort GetUShort(IRandomProvider provider)
result = RandomProviderExtensions.GetUShort(provider)

Returns any ushort.

provider
Source.

Returns: A ushort.