Enum Routines
20 nodes
On this page 20
Add Flag
FunctionSwitches on the bits of Flag in Value; for a flag enum, adds that option. Options already on stay on.
AddFlag(value: TEnum, flag: TEnum) -> TEnum
TEnum AddFlag(TEnum value, TEnum flag)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to start from; a value below zero throws System.OverflowException. |
| flag | TEnum | — | The flag or flags to add; a value below zero throws System.OverflowException. |
Returns
| Result | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Format
FunctionWrites an enum value as text in a chosen style: its name, its number in decimal or hexadecimal, or its flags spelled out by name.
Format(value: TEnum, format: Text) -> Text
string Format(TEnum value, string format)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to write. |
| format | Text | — | "G" for the name (or the number when it has none), "D" for decimal, "X" for hexadecimal, "F" for a comma-separated list of flag names; letter case does not matter. Null, empty or white-space throws System.ArgumentException, and any other format throws System.FormatException. |
Returns
| result | Text |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
From Value
FunctionTurns a number into the enum value with that number, for example a value read from a file or a database column.
FromValue(value: Any) -> TEnum
TEnum FromValue(object value)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | Any | — | The number to convert. Null throws System.ArgumentNullException; a value that cannot be converted throws System.InvalidCastException or System.FormatException; a number outside the underlying type's range throws System.OverflowException. |
Returns
| Result | TEnum |
Remarks
The number is first converted to the enum's underlying integer type using invariant culture: text holding a number works, and a fractional number is rounded to the nearest whole number (halves to even). The result is not checked against the declared constants; use EnumRoutines.TryFromDefinedValue for that.
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Enum Values
FunctionEvery value of an enum type chosen at run time, for when you only have the type as a value rather than as the node's type argument.
GetEnumValues(enumType: Type) -> Array
Array GetEnumValues(Type enumType)
Parameters
| name | type | default | description |
|---|---|---|---|
| enumType | Type | — | The enum type to list; null throws System.ArgumentNullException and a type that is not an enum throws System.ArgumentException. |
Returns
| result | Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Name
FunctionThe declared name of Value, or empty text when no constant has that exact value (for example a combination of flags without a name of its own).
GetName(value: TEnum) -> Text
string GetName(TEnum value)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to name. |
Returns
| result | Text |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Names
FunctionThe names of every constant the enum declares, for example to fill a drop-down list.
GetNames() -> Text Array
string[] GetNames()
Returns
| result | Text Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Underlying Type
FunctionThe integer type an enum stores its values in, which is System.Int32 unless the enum declares otherwise.
GetUnderlyingType() -> Type
Type GetUnderlyingType()
Returns
| result | Type |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Value List
FunctionEvery value the enum declares, as a read-only list; the same values in the same order as EnumRoutines.GetValues.
GetValueList() -> IReadOnlyList<TEnum>
IReadOnlyList<TEnum> GetValueList()
Returns
| result | IReadOnlyList<TEnum> |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Get Values
FunctionEvery value the enum declares, for example to go through all the choices one by one.
GetValues() -> TEnum Array
TEnum[] GetValues()
Returns
| result | TEnum Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Has Flag
FunctionWhether every bit set in Flag is also set in Value; for a flag enum, whether the value includes that option (or all of several combined options).
HasFlag(value: TEnum, flag: TEnum) -> Truth
bool HasFlag(TEnum value, TEnum flag)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The combined value to test; a value below zero throws System.OverflowException. |
| flag | TEnum | — | The flag or flags to look for; a zero flag is always present. A value below zero throws System.OverflowException. |
Returns
| result | Truth |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Is Defined
FunctionOverload 1 of 2
IsDefined(value: TEnum) -> Truth
bool IsDefined(TEnum value)
Whether Value is exactly one of the enum's named constants; use it to reject numbers that were cast or converted into the enum without matching any choice.
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to check. |
Returns
| result | Truth |
Remarks
A combination of flags counts as defined only when the enum gives that combination its own name.
Overload 2 of 2
IsDefined(name: Text) -> Truth
bool IsDefined(string name)
Whether the enum declares a constant called Name, matched exactly and case-sensitively.
Parameters
| name | type | default | description |
|---|---|---|---|
| name | Text | — | The name to look for; null, empty or white-space text answers false. A number in text form is not a name and answers false. |
Returns
| result | Truth |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Is Zero
FunctionWhether Value has no bits set at all; for a flag enum, whether no option is chosen.
IsZero(value: TEnum) -> Truth
bool IsZero(TEnum value)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to test; a value below zero throws System.OverflowException. |
Returns
| result | Truth |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Parse
FunctionTurns text into an enum value, throwing when it cannot; use EnumRoutines.TryParse when the text may be bad.
Parse(text: Text, ignoreCase: Truth) -> TEnum
TEnum Parse(string text, bool ignoreCase = true)
Parameters
| name | type | default | description |
|---|---|---|---|
| text | Text | — | The text to read. Null throws System.ArgumentNullException; empty, white-space or unrecognised text throws System.ArgumentException; a number too large for the enum's underlying type throws System.OverflowException. |
| ignoreCase | Truth | True | When true (the default), names match regardless of letter case. |
Returns
| Result | TEnum |
Remarks
The text may be a constant's name, a comma-separated list of names (combined as flags), or a number; a number is accepted even when no constant has that value, so check the result with EnumRoutines.IsDefined or use EnumRoutines.TryParseDefined if that matters.
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Remove Flag
FunctionSwitches off the bits of Flag in Value; for a flag enum, removes that option. Options already off stay off.
RemoveFlag(value: TEnum, flag: TEnum) -> TEnum
TEnum RemoveFlag(TEnum value, TEnum flag)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to start from; a value below zero throws System.OverflowException. |
| flag | TEnum | — | The flag or flags to remove; a value below zero throws System.OverflowException. |
Returns
| Result | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Toggle Flag
FunctionFlips the bits of Flag in Value: options that were on go off and options that were off come on.
ToggleFlag(value: TEnum, flag: TEnum) -> TEnum
TEnum ToggleFlag(TEnum value, TEnum flag)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to start from; a value below zero throws System.OverflowException. |
| flag | TEnum | — | The flag or flags to flip; a value below zero throws System.OverflowException. |
Returns
| Result | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Try From Defined Value
FunctionTurns a number into the enum value with that number only if it is one of the enum's named constants; answers false for null, unconvertible or undeclared values instead of throwing.
TryFromDefinedValue(value: Any) -> (result: Truth, result: TEnum)
bool TryFromDefinedValue(object value, out TEnum result)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | Any | — | The number to convert; may be null. |
Returns
| result | Truth |
| result | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Try From Value
FunctionTurns a number into the enum value with that number like EnumRoutines.FromValue, but answers false instead of throwing when the value is null or cannot be converted.
TryFromValue(value: Any) -> (result: Truth, result: TEnum)
bool TryFromValue(object value, out TEnum result)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | Any | — | The number to convert; may be null. |
Returns
| result | Truth |
| result | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Try Get Name
FunctionThe declared name of Value, or null when no constant has that exact value; unlike EnumRoutines.GetName, this lets you tell "no name" apart from a name.
TryGetName(value: TEnum) -> Text
string TryGetName(TEnum value)
Parameters
| name | type | default | description |
|---|---|---|---|
| value | TEnum | — | The value to name. |
Returns
| result | Text |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Try Parse
FunctionTurns text into an enum value without throwing, telling you whether it succeeded; it accepts the same text as EnumRoutines.Parse, including numbers that match no named constant.
TryParse -> (result: Truth, value: TEnum)
text: Text
ignoreCase: Truthbool TryParse(
string text,
out TEnum value,
bool ignoreCase = true)Parameters
| name | type | default | description |
|---|---|---|---|
| text | Text | — | The text to read; null, empty or unrecognised text answers false. |
| ignoreCase | Truth | True | When true (the default), names match regardless of letter case. |
Returns
| result | Truth |
| value | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library
Try Parse Defined
FunctionTurns text into an enum value only if the result is one of the enum's named constants, so stray numbers and unnamed flag combinations are rejected; use it for validating user input.
TryParseDefined -> (result: Truth, value: TEnum)
text: Text
ignoreCase: Truthbool TryParseDefined(
string text,
out TEnum value,
bool ignoreCase = true)Parameters
| name | type | default | description |
|---|---|---|---|
| text | Text | — | The text to read; null, empty or unrecognised text answers false. |
| ignoreCase | Truth | True | When true (the default), names match regardless of letter case. |
Returns
| result | Truth |
| value | TEnum |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Enum Routines
- Package
- Standard Library