Summary
Gets an environment variable as an enum.
- Namespace
- Cake
.Common .Build .GitLabCI - Containing Type
- GitLabCIInfo
Syntax
protected TEnum? GetEnvironmentEnum<TEnum>(string variable) where TEnum : struct, Enum
Remarks
By default, the environment variable value is presumed to be identical to the enum value name.
To define a mapping between environment variable value and enum name, apply the
System.Runtime.Serialization.EnumMemberAttribute
attribue in the enum definition.
Parsing is case-insensitive.
Type Parameters
Name | Description |
---|---|
TEnum | The type of the enum to return. |
Parameters
Name | Type | Description |
---|---|---|
variable | string | The primary environment variable name. |
Return Value
Type | Description |
---|---|
TEnum? |
The environment variable value converted to the corresponding value of TEnum or
null if the variable is not set or the value could not be converted to the the specified enum type.
|