Steps to Reproduce
- Create and register a custom Action and configure it in a workflow.
- Create a Ruleparameter and set the Value to an ExpandoObject with data that will trigger rule success for the workflow. Call RuleEngine.ExecuteAllRulesAsync with the RuleParameter as an argument.
- Check the type of RuleParameter.Value in the custom action ( Actionbase.Run).
Expected Behavior
Cast RuleParameter.Value as ExpandoObject and access the properties and data.
Observed Behavior
The cast result is a null value. The underlying type of RuleParameter.Value is no longer an ExpandoObject. Utils.GetTypedObject is called in the constructor of RuleParameter which changes the type of the object to an anonymous runtime type.
Suggested Next Steps
Add a property to RuleParameter which preserves the original type and value of the Value property which is not change via Utils.GetTypedObject. (e.g. RuleProperty.OriginalValue). This will provide access to the RuleParameter input data in the same manner as the data was created.
This problem makes it difficult to safely access data from the RuleParameters (i.e. the input data) in the custom Action. I need to extract data from the RuleParameter that is optional. If I access the data as a dynamic, I cannot check to see if the optional property exists before access without exceptions.
I also attempted to create a new class, CustomRuleParameter, which inherits from RuleParaemter. I added a property, CustomRuleParameter.OriginalValue which preserves the original Value object. I then passed this object to RuleEngine.ExecuteAllRulesAsync. I was unable to cast the RuleParameter back to CustomRuleParameter in Actionbase.Run. The original RuleParameter is not preserved.
Steps to Reproduce
Expected Behavior
Cast RuleParameter.Value as ExpandoObject and access the properties and data.
Observed Behavior
The cast result is a null value. The underlying type of RuleParameter.Value is no longer an ExpandoObject. Utils.GetTypedObject is called in the constructor of RuleParameter which changes the type of the object to an anonymous runtime type.
Suggested Next Steps
Add a property to RuleParameter which preserves the original type and value of the Value property which is not change via Utils.GetTypedObject. (e.g. RuleProperty.OriginalValue). This will provide access to the RuleParameter input data in the same manner as the data was created.
This problem makes it difficult to safely access data from the RuleParameters (i.e. the input data) in the custom Action. I need to extract data from the RuleParameter that is optional. If I access the data as a dynamic, I cannot check to see if the optional property exists before access without exceptions.
I also attempted to create a new class, CustomRuleParameter, which inherits from RuleParaemter. I added a property, CustomRuleParameter.OriginalValue which preserves the original Value object. I then passed this object to RuleEngine.ExecuteAllRulesAsync. I was unable to cast the RuleParameter back to CustomRuleParameter in Actionbase.Run. The original RuleParameter is not preserved.