OLAX.InnovativeLab.RulesEngine
1.0.2
dotnet add package OLAX.InnovativeLab.RulesEngine --version 1.0.2
NuGet\Install-Package OLAX.InnovativeLab.RulesEngine -Version 1.0.2
<PackageReference Include="OLAX.InnovativeLab.RulesEngine" Version="1.0.2" />
<PackageVersion Include="OLAX.InnovativeLab.RulesEngine" Version="1.0.2" />
<PackageReference Include="OLAX.InnovativeLab.RulesEngine" />
paket add OLAX.InnovativeLab.RulesEngine --version 1.0.2
#r "nuget: OLAX.InnovativeLab.RulesEngine, 1.0.2"
#:package OLAX.InnovativeLab.RulesEngine@1.0.2
#addin nuget:?package=OLAX.InnovativeLab.RulesEngine&version=1.0.2
#tool nuget:?package=OLAX.InnovativeLab.RulesEngine&version=1.0.2
OLAX.InnovativeLab.RulesEngine
A lightweight, flexible rules engine wrapper for .NET 8+.
This package provides a file-based storage implementation for the Microsoft RulesEngine, designed for seamless integration into ASP.NET Core applications with built-in Dependency Injection support.
Features
- JSON File Storage: Manage workflow definitions easily using local JSON files.
- Dependency Injection Ready: Native
IServiceCollectionextension methods for quick setup. - Custom Functions Support: Execute complex business logic by injecting your own C# services into rule expressions.
- Scoped Parameters: Full support for scoped parameters in rule execution.
- Caching: Built-in caching for workflow definitions to ensure high performance.
Installation
Install the package from your NuGet feed:
dotnet add package OLAX.InnovativeLab.RulesEngine
Getting Started
1. Configure Services (Program.cs)
Register the rules engine in your application startup. You can point it to your storage directory and register any custom types you intend to use within your rules.
using OLAX.InnovativeLab.RulesEngine.DI;
var builder = WebApplication.CreateBuilder(args);
// Define where your JSON rule files are located
var rulesPath = builder.Configuration.GetValue<string>("Storage:JsonFilePath")
?? AppContext.BaseDirectory;
builder.Services.AddOlaxRulesEngine(
configureEngine: opt =>
{
opt.WorkflowCacheTtl = TimeSpan.FromMinutes(5); // Cache duration
opt.EnableScopedParams = true;
// IMPORTANT: Register types here to use their methods in rule expressions
// opt.CustomTypes.Add(typeof(Inventory.API.Services.CustomRuleFunctionsService));
},
configureStore: store =>
{
store.BasePath = rulesPath;
store.FolderName = "Rules"; // Subfolder name
});
2. Create a Rule File
Create a JSON file (e.g., OrderValidation.json) in your storage
folder:
[
{
"WorkflowName": "OrderValidation",
"Rules": [
{
"RuleName": "CheckStock",
"ErrorMessage": "Insufficient stock available.",
"Expression": "CurrentStock < RequestedQuantity",
"SuccessEvent": "StockLow"
}
]
}
]
3. Execute Rules
Inject IRulesEngineService into your controller or service and execute
the workflow.
public class OrderController : ControllerBase
{
private readonly IRulesEngineService _rulesEngine;
public OrderController(IRulesEngineService rulesEngine)
{
_rulesEngine = rulesEngine;
}
[HttpPost("validate")]
public async Task<IActionResult> ValidateOrder(OrderRequest request)
{
var inputs = new Dictionary<string, object>
{
["CurrentStock"] = 50,
["RequestedQuantity"] = request.Quantity
};
var result = await _rulesEngine.ExecuteRuleAsync(
"OrderValidation",
"CheckStock",
inputs
);
if (result.IsSuccess)
{
return BadRequest(result.ErrorMessage);
}
return Ok("Order Validated");
}
}
Advanced Usage: Custom Functions
You can execute complex C# logic inside your JSON rules (e.g., calculating dynamic tax or calling external validators).
1. Define & Register Your Service
opt.CustomTypes.Add(typeof(MyCustomFunctions));
2. Inject the Instance at Runtime
var inputs = new Dictionary<string, object>
{
["unitPrice"] = 100,
["taxRate"] = 0.15,
["customFunctions"] = _myCustomFunctionsService
};
await _rulesEngine.ExecuteRuleAsync(
"TaxWorkflow",
"CalculateTax",
inputs
);
3. Call it in JSON
{
"RuleName": "CalculateTax",
"Actions": {
"OnSuccess": {
"Name": "OutputExpression",
"Context": {
"Expression": "customFunctions.CalculateTax(unitPrice, taxRate)"
}
}
}
}
License
Proprietary License (Freeware)
Copyright (c) 2026 OLAX Innovative Lab. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software package, to use the Software in personal, non-commercial, and commercial applications.
You may NOT modify, reverse engineer, or disassemble the Software.
You may NOT redistribute the source code.
See the LICENSE.txt file in the package for full license details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Options (>= 10.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.2)
- RulesEngine (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.