hiren bhudrani
hiren bhudrani

Reputation: 31

Codeeffect rule editor allows to select only one action even though there are multiple actions to select from

I have requirements to use codeeffect rule editor for our feature. We have dynamic actions to render in the rule editor which user can select from.

So for that i have created the rule editor using FlexSource type. I tried to configure actions in rule editor by adding FlexMethodInfo for each actions and configured ActionAttributes for each of them. e.g. the actions are "SetAmount", "SetPercentage" and "SetQuantity" .

It successfully renders the editor and provides the above three options to select from. But which ever option i select it only selects "SetAmount" and shows that in rule editor.

Screenshot 1

Screenshot 2

Screenshot 3

Screenshot 4

Screenshot 5

Upvotes: 3

Views: 201

Answers (1)

Ruslan
Ruslan

Reputation: 1761

The idea behind FlexSource is to subclass System.Type so that Editor can continue using reflection to enumerate methods, properties, fields, etc.

To do that, there is a minimum number of classes and methods that have to be implemented. The Flex demo shows which those are.

However current version is missing an override for FlexMethodInfo.ToString().

Please add following to your FlexMethodInfo class. Adjust return values to reflect your actual methods and their signatures. The Editor uses ToString() to build hashes and match methods. It follows the same logic as MethodInfo.ToString().

public override string ToString()
{
    switch (methodName)
    {
        case "Concatenate":
            return "System.String Concatenate(System.String, System.String)";
        case "Register":
            return "Register()";
        case "Confirm":
            return "Confirm(System.String)";
        default:
            return base.ToString();
    }
}

Make sure to get latest NuGet packages for the Editor and Engine. I believe they have released an update that addresses some use cases.

Upvotes: 1

Related Questions