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, int)
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
countis 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
convertiblesIEnumerable<IConvertible>A sequence of objects implementing the IConvertible interface.
Returns
- int
A 32-bit signed integer that is the hash code of
convertibles.
HashCode32(params IConvertible[])
Computes a suitable hash code from the variable number of convertibles.
public static int HashCode32(params IConvertible[] convertibles)
Parameters
convertiblesIConvertible[]A variable number of objects implementing the IConvertible interface.
Returns
- int
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
convertiblesIEnumerable<IConvertible>A sequence of objects implementing the IConvertible interface.
Returns
- long
A 64-bit signed integer that is the hash code of
convertibles.
HashCode64(params IConvertible[])
Computes a suitable hash code from the variable number of convertibles.
public static long HashCode64(params IConvertible[] convertibles)
Parameters
convertiblesIConvertible[]A variable number of objects implementing the IConvertible interface.
Returns
- long
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
instanceobjectThe instance of an Object to convert.
setupAction<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(int)
Generates a random integer that is within a specified range.
public static int RandomNumber(int maximumExclusive = 2147483647)
Parameters
maximumExclusiveintThe exclusive upper bound of the random number returned.
maximumExclusivemust be greater than or equal to 0.
Returns
- int
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(int, int)
Generates a random integer that is within a specified range.
public static int RandomNumber(int minimumInclusive, int maximumExclusive)
Parameters
minimumInclusiveintThe inclusive lower bound of the random number returned.
maximumExclusiveintThe exclusive upper bound of the random number returned.
maximumExclusivemust be greater than or equal tominimumInclusive.
Returns
- int
A 32-bit signed integer greater than or equal to
minimumInclusiveand less thanmaximumExclusive; that is, the range of return values includesminimumInclusivebut notmaximumExclusive. IfminimumInclusiveequalsmaximumExclusive,minimumInclusiveis returned.
Exceptions
- ArgumentOutOfRangeException
minimumInclusiveis greater thanmaximumExclusive.
RandomString(int)
Generates a random string with the specified length using values of LettersAndNumbers.
public static string RandomString(int length)
Parameters
lengthintThe length of the random string to generate.
Returns
- string
A random string from the values of LettersAndNumbers.
RandomString(int, params string[])
Generates a random string with the specified length from the provided values.
public static string RandomString(int length, params string[] values)
Parameters
lengthintThe length of the random string to generate.
valuesstring[]The values to use in the randomization process.
Returns
- string
A random string from the values provided.
Exceptions
- ArgumentNullException
valuescannot be null.- ArgumentException
valuescontains no elements.
RangeOf<T>(int, Func<int, T>)
Generates a sequence of T within a specified range.
public static IEnumerable<T> RangeOf<T>(int count, Func<int, T> generator)
Parameters
countintThe number of
Tto generate.generatorFunc<int, 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
Telements.
Type Parameters
TThe type of the elements to return.
Exceptions
- ArgumentOutOfRangeException
countis less than 0.