Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Rulez is the simplest possible Rule engine I can imagine for .NET.

##Facts and Rules

A Rule is specified by a .NET delegate (Action), that uses Facts for its computation.

To specify a Rule, use


A Fact represents a mutable value. To create a Fact, use either

var integerValue = Fact.of(10);


var myInt = Fact.of<int>();

To change a Fact, assign a value to it:

myInt.Value = 4;

A Rule is evaluated in the context of the current Dispatcher.

While a Rule is evaluated, all Facts that are accessed are tracked.

A Rule has a lifetime. When it is active, it is automatically reevaluated as soon one of its referred Facts change. To deactivate a Rule call Dispose() on the return value of Rule.activate().

Rules may change other Facts.

For example, the following code keeps the result variable always at two times the input variable:

var input = Fact.of(0);
int result = 0;
Rule.activate(() => result = input.Value*2);

Note that the evaluation is deferred through the .NET Dispatcher. This means that the evaluation results may not be updated immediately.


A RuleSet combines multiple Rules together.

To create a custom RuleSet, create a class that derives from RuleSet.

To add a Rule to your RuleSet, create a method that contains the Rule logic and attribute it with [Rule].

Any [Rule] attributed method in a RuleSet derived class is automatically activated as a Rule when the RuleSet class is instantiated.

To deactivate the RuleSet call its Dispose() method.

TBD: Examples


Rulez, a minimalistic rule evaluation engine.




No releases published


You can’t perform that action at this time.