I am getting started with NRules. Here's an outline of some key requirements for the application I am building:
Some of the rules determine if groups of other rules should be applied. For example (in pseudo code): "when the type of
vehicle
is car, apply all rules applying to cars".Some rules will determine that specific rules should be excluded.
There may be many types of
vehicle
; ideally I don't want to load all the rules for all vehicles at start-up.
This implies that rules should be organised into modules that are enabled/disabled somehow during execution. A few solutions have occurred to me:
Tag rules and use Agenda filters to filter the rules depending on a service that is used to enable/disable rules from being added to the agenda. I have tried this and it doesn't quite work as I would like, because a change to the service is not picked up by the engine.
Add rules that determine if rules should be applied, and use this in each rule's Match condition. This results in a lot of repeated code in each rule, which I don't like much.
Load new groups of rules during rule execution. I'm not sure how to do this, if it is recommended or should be expected to work.
Is there a correct way to do what I am trying to do?