1

I followed the demo project here https://codeeffects.com/Doc/Business-Rule-Flex-Source for a sample of how the Flex properties work. My rules are evaluated correctly, but the editor does not show the fields.

I have looked at all of the properties of the FlexPropertyInfo object and confirmed that they set as I would expect. What else should I try in order to troubleshoot this?

Stuart
  • 11
  • 1

1 Answers1

1
  1. Make sure that your Flex type inherits from Type and implements the minimum required properties and methods, and GetProperties in particular, e.g.:

     public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
     {
         List<FlexPropertyInfo> properties = new List<FlexPropertyInfo>();
         properties.Add(new FlexPropertyInfo("Id", typeof(int), typeName));
         properties.Add(new FlexPropertyInfo("Name", typeof(string), typeName));
    
         return properties.ToArray();
     }
    
  2. Make sure that you pass a new instance of your Flex type and not the type itself.

     RuleEditor editor = new RuleEditor("divRuleEditor")
     {
         Mode = Common.RuleType.Execution,
         SourceType = new MyFlexType() //and not typeof(MyFlexType)
     }
    

The Editor itself knows nothing about Flex. As far as it is concerned it is another type and it is using reflection to pull the list of all members. Which is why it is important to pass an instance of your type. Otherwise you will get reflection on the Type class instead. Same goes for properties and other Flex objects.

Ruslan
  • 1,761
  • 9
  • 16