codeeffects

Exclude recursive properties after 3 level from business rule engine


I'm using codeeffect for my business rule engine. I have a user class with manager property with user type.

public class BasicUser
{
public int ID { get; set; }
public string Name { get; set; }
public BasicUser Manager { get; set; }
}

In the business rule engine currently showing User.Manager.Manager.Manage.Manager.ID But I would like to show only 2 levels like User.Manager.Manager.ID

Is there any attribute I can use?


Solution

  • You can use the ParentAttribute to set display names of your User class. Details can be found here.

    UPDATED: You can also use the SourceAttribute.MaxTypeNestingLevel property to control the number of hierarchy levels of your source object and all reference types it declares. Details are here. Use the ExcludeFromEvaluationAttribute class to remove any source member from the editor and, consequently, from evaluation. Its documentation is here

    UPDATE 2: Consider the following two classes:

    public class Address
    {
        public Address() { }
    
        public string Street { get; set; }
        public Address InnerAddress { get; set; }
    }
    
    [Source(MaxTypeNestingLevel = 1)]
    public class Patient
    {
        public Patient() { }
    
        public string Name { get; set; }
        public Address InnerAddress { get; set; }
    }
    

    If I give the Patient class to the rule editor as its source and set the value of the nested levels to 1 or less I get the following menu options:

    (
    Name
    

    I.e the editor ignores all reference types in the source because the level is 1.

    If I give it level 2 I see the following options in the menu:

    (
    InnerAddress.Street
    Name
    

    The editor shows the InnerAddress instance (level one) with its Street property (level 2).

    And if I set the level to 4 I get these options:

    (
    InnerAddress.InnerAddress.InnerAddress.Street
    InnerAddress.InnerAddress.Street
    InnerAddress.Street
    Name
    

    Obviously, options are shown up to the level 4 now. All this options are tested on one of Code Effects demo projects.