Class Generate
Provides a set of static methods for generating different types of values or sequences of values.
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class Generate
Methods
| Improve this Doc View SourceFixedString(Char, Int32)
Generates a string from the specified Unicode character repeated until the specified length.
Declaration
public static string FixedString(char c, int count)
Parameters
Type | Name | Description |
---|---|---|
Char | c | A Unicode character. |
Int32 | count | The number of times |
Returns
Type | Description |
---|---|
String | A String filled with the specified |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
HashCode32(IEnumerable<IConvertible>)
Computes a suitable hash code from the specified sequence of convertibles
.
Declaration
public static int HashCode32(IEnumerable<IConvertible> convertibles)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IConvertible> | convertibles | A sequence of objects implementing the IConvertible interface. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that is the hash code of |
HashCode32(IConvertible[])
Computes a suitable hash code from the variable number of convertibles
.
Declaration
public static int HashCode32(params IConvertible[] convertibles)
Parameters
Type | Name | Description |
---|---|---|
IConvertible[] | convertibles | A variable number of objects implementing the IConvertible interface. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that is the hash code of |
HashCode64(IEnumerable<IConvertible>)
Computes a suitable hash code from the specified sequence of convertibles
.
Declaration
public static long HashCode64(IEnumerable<IConvertible> convertibles)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IConvertible> | convertibles | A sequence of objects implementing the IConvertible interface. |
Returns
Type | Description |
---|---|
Int64 | A 64-bit signed integer that is the hash code of |
HashCode64(IConvertible[])
Computes a suitable hash code from the variable number of convertibles
.
Declaration
public static long HashCode64(params IConvertible[] convertibles)
Parameters
Type | Name | Description |
---|---|---|
IConvertible[] | convertibles | A variable number of objects implementing the IConvertible interface. |
Returns
Type | Description |
---|---|
Int64 | A 64-bit signed integer that is the hash code of |
ObjectPortrayal(Object, Action<ObjectPortrayalOptions>)
Generates a portrayal of the specified instance
that might contain information about the instance state.
Declaration
public static string ObjectPortrayal(object instance, Action<ObjectPortrayalOptions> setup = null)
Parameters
Type | Name | Description |
---|---|---|
Object | instance | The instance of an Object to convert. |
Action<ObjectPortrayalOptions> | setup | The ObjectPortrayalOptions which may be configured. |
Returns
Type | Description |
---|---|
String | A String that represents the specified |
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.
Declaration
public static int RandomNumber(int maximumExclusive = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
Int32 | maximumExclusive | The exclusive upper bound of the random number returned. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer greater than or equal to 0 and less than |
RandomNumber(Int32, Int32)
Generates a random integer that is within a specified range.
Declaration
public static int RandomNumber(int minimumInclusive, int maximumExclusive)
Parameters
Type | Name | Description |
---|---|---|
Int32 | minimumInclusive | The inclusive lower bound of the random number returned. |
Int32 | maximumExclusive | The exclusive upper bound of the random number returned. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer greater than or equal to |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
RandomString(Int32)
Generates a random string with the specified length using values of LettersAndNumbers.
Declaration
public static string RandomString(int length)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The length of the random string to generate. |
Returns
Type | Description |
---|---|
String | A random string from the values of LettersAndNumbers. |
RandomString(Int32, String[])
Generates a random string with the specified length from the provided values.
Declaration
public static string RandomString(int length, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The length of the random string to generate. |
String[] | values | The values to use in the randomization process. |
Returns
Type | Description |
---|---|
String | A random string from the values provided. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
RangeOf<T>(Int32, Func<Int32, T>)
Generates a sequence of T
within a specified range.
Declaration
public static IEnumerable<T> RangeOf<T>(int count, Func<int, T> generator)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | The number of |
Func<Int32, T> | generator | The function delegate that will resolve the instance of |
Returns
Type | Description |
---|---|
IEnumerable<T> | An IEnumerable<T> that contains a range of |
Type Parameters
Name | Description |
---|---|
T | The type of the elements to return. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|