Data Types
Enforcer provides the following data types for use in ALFA attributes:
Integer
ALFA type name: integer
.Net type: System.Long
Remarks: All integers in Enforcer are 64-bit. In ALFA, integer literal values are specified in base 10. Eg. 15
represents the number fifteen.
Example ALFA attribute declaration
attribute IntegerAttribute
{
type = integer
. . .
}
Double
ALFA type name: double
.Net type: System.Double
Remarks: All floating point numbers in Enforcer are double precision. In ALFA, any literal value with a decimal separator is treated as a double. Eg. 15.2
represents the number fifteen point two.
Example ALFA attribute declaration
attribute DoubleAttribute
{
type = double
. . .
}
Boolean
ALFA type name: boolean
.Net type: System.Boolean
Remarks: Literal values in ALFA are true
and false
Example ALFA attribute declaration
attribute BooleanAttribute
{
type = boolean
. . .
}
String
ALFA type name: string
.Net type: System.String
Remarks: Literal strings in ALFA can be enclosed in either single or double quotes.
Example ALFA attribute declaration
attribute StringAttribute
{
type = string
. . .
}
Date
ALFA type name: date
.Net type: Rsk.Enforcer.PolicyModels.Date
Remarks: Represents a calendar date. Literal values in ALFA are specified with a string in the format yyyy-MM-dd
that can be parsed to a date, followed by the date type specifier. Eg. "2021-01-08":date
is the ALFA literal for January the 8th, 2021.
Example ALFA attribute declaration
attribute DateAttribute
{
type = date
. . .
}
Time
ALFA type name: time
.Net type: Rsk.Enforcer.PolicyModels.Time
Remarks: Represents a time of day. Literal values in ALFA are specified with a string that can be parsed to a time, followed by the time type specifier. Eg. "12:57:00":time
.
Valid formats are HH:mm:ss
and HH:mm:sszzz
. Times are assumed to be local time rather than UTC.
Example ALFA attribute declaration
attribute TimeAttribute
{
type = time
. . .
}
DateTime
ALFA type name: dateTime
.Net type: System.DateTime
Remarks: Represents a point in time with both a calendar date and time of day. Literal values in ALFA are specified with a string that can be parsed to a .Net DateTime
, followed by the ALFA dateTime
type specifier. Eg. "2021-01-08 12:57:00":dateTime
Example ALFA attribute declaration
attribute DateTimeAttribute
{
type = dateTime
. . .
}
Duration
ALFA type name: duration
.Net type: System.TimeSpan
Remarks: A duration represents the difference between two dates, times or dateTimes.
Literal values in ALFA are specified with a string followed by the duration type specifier, Eg. "3:10:59":duration
represents 3 hours, ten minutes and 59 seconds.
The string component has many acceptable formats:
- Any string which can be directly parsed to a .Net
TimeSpan
is acceptable. - Any string duration in ISO-8601 format. Eg.
P12D6H4M
, representing the period of 12 days, 6 hours, 4 minutes.
Example ALFA attribute declaration
attribute IntegerAttribute
{
type = integer
. . .
}