Enums
Introduction
To Code provides the ability to define an Enum based the defined the various constants and fixed values used across your Code Model and business logic.
Enums, short for "enumerations," are a data type in many programming languages that allow a variable to be a set of predefined constants.
They are used to represent a collection of related values in a more readable and manageable way, often improving code clarity and reducing errors.
Syntax
LogicalId
{
"LogicalId": "RoleType",
}
- Description: suggests the unique name or identifier of the enum. It typically describes the common purpose of the values in the enumeration.
Description
{
"Description": "used to help in how to render the question at the presentation layer",
}
- Description: the field provides additional context on how or why the enumeration is used.
Values
{
"Values": [
"Editor",
"Admin"
]
}
- Description: This array lists indicates the possible values that the enum can take.
Example
This document describes the setup and functionality of the Enum RoleType
configuration used for the possible values that the enum can take as Editor
.
{
"LogicalId": "RoleType",
"Description": "used to help in how to render the question at the presentation layer",
"Values": [
"Editor",
"Admin"
]
}
Output
To Code you provided is a C# Enum named RoleType
.
{
public enum RoleType
{
[EnumMember(Value = "Admin")]
Admin = 0,
[EnumMember(Value = "Editor")]
Editor = 1,
}
}