LogicEngine library

WBS_200px-iconToday I published my first NuGet package, LogicEngine library (also on GitHub). This is a small logic engine that enforces a good separation of logic rules from your model.

The LogicEngine library is designed to run arbitrary rules or bits of logic against a given model. It’s written in C# .NET 4.5.1.

This project is born out of a DRY (don’t repeat yourself) mentality. In other words, I was using the same code on several projects.

How to use

The source code has a working example (ExampleEngine) which shows how easy the logic engine is to use.


The only real requirement is to implement the IRule interface:

In the ExampleEngine, the AddRule class looks like this:

The EngineResult class can be implemented, or you can use your own. The Engine returns a list of EngineResults. You can add any information you’d like.

Once the rules are created, you only need to create an engine with them and execute the rules against the model.

Note : You should use dependency injection here.

Bumper Rules

The engine has some “bumper rules”. They’re rules that run before/after all your rules. They will give you run start/stop times.

Dependency Injection Support

You can use dependency injection to add your rules. Simply add them to the RulesCollection.