This is a detailed topic in our support portal in the Using migFx series and assumes that you have some prior knowledge or experience using migFx. If you want to know more about hopp tech and migFx, our comprehensive solution for complex data migration, please visit our web site hopp.tech. |
The Any data type is available from Hopp version 2.3. It is specifically and only for use when defining parameters to
- Manual Rules
- Manual Bag Methods
- Events
This allow 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 - is 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.
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. The allows a method implementation to inspect the type of the actual value passed and act accordingly:
public override bool FlexibleRule(FlagHandler flag, object any) { // if/else 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; }
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article