Skip to main content

The 'Any' Data Type

The Any data type is specifically and only for use when defining parameters to:

  • Manual Rules
  • Manual Bag Methods
  • Events

This allows values of any type to be passed to a parameter with the new Any type.

A typical use-case is, for instance, a validation rule that checks a parameter for null. In previous versions - without the Any type - it would be necessary with a specific rule for each data type that needed to be checked: IsDateNull, IsNumNull, etc.

With the Any data type this can be done with just 1 rule - IsNull - by defining the parameter to the rule to be of the Any type.

Any DataType on Parameter

Using the rule, you can now pass fields with any data type to this parameter:

Any DataType Usage

In the generated C# code for the corresponding method, the type of the parameter will be object allowing values of any C# type.

Even though the method parameter is defined as object, the value passed to the parameter when the engine is running is in fact a strongly typed value. That allows a method implementation to inspect the type of the actual value passed and act accordingly:

public override bool FlexibleRule(FlagHandler flag, object any) // The any parameter is of type: object
{
// if/else approach
if (any is DateTime date)
{
// Do something with the date
}
else if (any is decimal num)
{
// Do something with the num value
}

// Or a switch on type
switch (any)
{
case DateTime date:
// Do something with the date
break;
case decimal num:
// Do something with the num value
break;
}

return true;
}