Class Generate
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Provides a set of static methods for generating different types of values or sequences of values.
public static class Generate
- Inheritance
-
Generate
Methods
FixedString(Char, Int32)
Generates a string from the specified Unicode character repeated until the specified length.
public static string FixedString(char c, int count)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
count
is less than zero.
HashCode32(IEnumerable<IConvertible>)
Computes a suitable hash code from the specified sequence of convertibles
.
public static int HashCode32(IEnumerable<IConvertible> convertibles)
Parameters
convertibles
IEnumerable<IConvertible>A sequence of objects implementing the IConvertible interface.
Returns
- Int32
A 32-bit signed integer that is the hash code of
convertibles
.
HashCode32(IConvertible[])
Computes a suitable hash code from the variable number of convertibles
.
public static int HashCode32(params IConvertible[] convertibles)
Parameters
convertibles
IConvertible[]A variable number of objects implementing the IConvertible interface.
Returns
- Int32
A 32-bit signed integer that is the hash code of
convertibles
.
HashCode64(IEnumerable<IConvertible>)
Computes a suitable hash code from the specified sequence of convertibles
.
public static long HashCode64(IEnumerable<IConvertible> convertibles)
Parameters
convertibles
IEnumerable<IConvertible>A sequence of objects implementing the IConvertible interface.
Returns
- Int64
A 64-bit signed integer that is the hash code of
convertibles
.
HashCode64(IConvertible[])
Computes a suitable hash code from the variable number of convertibles
.
public static long HashCode64(params IConvertible[] convertibles)
Parameters
convertibles
IConvertible[]A variable number of objects implementing the IConvertible interface.
Returns
- Int64
A 64-bit signed integer that is the hash code of
convertibles
.
ObjectPortrayal(Object, Action<ObjectPortrayalOptions>)
Generates a portrayal of the specified instance
that might contain information about the instance state.
public static string ObjectPortrayal(object instance, Action<ObjectPortrayalOptions> setup = null)
Parameters
instance
ObjectThe instance of an Object to convert.
setup
Action<ObjectPortrayalOptions>The ObjectPortrayalOptions which may be configured.
Returns
Remarks
When determining the representation of the specified instance
, these default rules applies:
1: if the ToString() method has been overridden, any further processing is skipped (the assumption is, that a custom representation is already in place)
2: any public properties having index parameters is skipped
3: any public properties is appended to the result if ToString() has not been overridden
Note: do not call this method from an overridden ToString(..) method without setting BypassOverrideCheck to true
; otherwise a StackOverflowException will occur.
RandomNumber(Int32)
Generates a random integer that is within a specified range.
public static int RandomNumber(int maximumExclusive = 2147483647)
Parameters
maximumExclusive
Int32The exclusive upper bound of the random number returned.
maximumExclusive
must be greater than or equal to 0.
Returns
- Int32
A 32-bit signed integer greater than or equal to 0 and less than
maximumExclusive
; that is, the range of return values includes 0 but notmaximumExclusive
. If 0 equalsmaximumExclusive
, 0 is returned.
RandomNumber(Int32, Int32)
Generates a random integer that is within a specified range.
public static int RandomNumber(int minimumInclusive, int maximumExclusive)
Parameters
minimumInclusive
Int32The inclusive lower bound of the random number returned.
maximumExclusive
Int32The exclusive upper bound of the random number returned.
maximumExclusive
must be greater than or equal tominimumInclusive
.
Returns
- Int32
A 32-bit signed integer greater than or equal to
minimumInclusive
and less thanmaximumExclusive
; that is, the range of return values includesminimumInclusive
but notmaximumExclusive
. IfminimumInclusive
equalsmaximumExclusive
,minimumInclusive
is returned.
Exceptions
- ArgumentOutOfRangeException
minimumInclusive
is greater thanmaximumExclusive
.
RandomString(Int32)
Generates a random string with the specified length using values of LettersAndNumbers.
public static string RandomString(int length)
Parameters
length
Int32The length of the random string to generate.
Returns
- String
A random string from the values of LettersAndNumbers.
RandomString(Int32, String[])
Generates a random string with the specified length from the provided values.
public static string RandomString(int length, params string[] values)
Parameters
length
Int32The length of the random string to generate.
values
String[]The values to use in the randomization process.
Returns
- String
A random string from the values provided.
Exceptions
- ArgumentNullException
values
cannot be null.- ArgumentException
values
contains no elements.
RangeOf<T>(Int32, Func<Int32, T>)
Generates a sequence of T
within a specified range.
public static IEnumerable<T> RangeOf<T>(int count, Func<int, T> generator)
Parameters
count
Int32The number of
T
to generate.generator
Func<Int32, T>The function delegate that will resolve the instance of
T
; the parameter passed to the delegate represents the index (zero-based) of the element to return.
Returns
- IEnumerable<T>
An IEnumerable<T> that contains a range of
T
elements.
Type Parameters
T
The type of the elements to return.
Exceptions
- ArgumentOutOfRangeException
count
is less than 0.