A flexible and lightweight logic flow engine for IoT and automation scenarios. Supports dynamic rule loading, condition validation, and action handling. Compatible with .NET Standard 2.0+, .NET Core 2.0+, .NET Framework 4.6.1+, and .NET 5+. Fully supports .NET 6, 8, 9, and 10.
$ dotnet add package FlowLogicEngineA flexible and lightweight logic flow engine for .NET 8, designed for IoT and automation scenarios.
name:condition=>action&&, ||)>, <, >=, <=, ==, !=)| Target Framework | Status |
|---|---|
| .NET Standard 2.0 | ✅ Supported |
| .NET Standard 2.1 | ✅ Supported |
| .NET 6.0 | ✅ Supported |
| .NET 8.0 | ✅ Supported |
| .NET 9.0 | ✅ Supported |
| .NET 10.0 | ✅ Supported |
| .NET Framework 4.6.1+ | ✅ Supported |
| .NET Core 2.0+ | ✅ Supported |
| Xamarin | ✅ Supported |
| Unity 2018.1+ | ✅ Supported |
See COMPATIBILITY.md for detailed compatibility information.
dotnet add package FlowLogicEngine
using FlowLogicEngine;
using FlowLogicEngine.Core;
// Create logic flow processor with default configuration
var processor = new LogicFlowBuilder()
.UseDefaults()
.Build();
// Add rules
processor.AddLogicRule(new LogicRule("HighTemp", "temperature > 30", "SendAlert(Temperature too high: {temperature}°C)"));
processor.AddLogicRule(new LogicRule("LowBattery", "battery < 20", "LogWarning(Battery low: {battery}%)"));
// Create context data
var context = new ContextData();
context.AddFact("temperature", 35);
context.AddFact("battery", 15);
// Execute rules
processor.ExecuteLogicRules(context);
Output:
🚨 [ALERT] Temperature too high: 35°C
⚠️ [WARNING] Battery low: 15%
var rulesString = @"
HighTemperature:temperature > 30=>SendAlert(Temperature too high)
LowHumidity:humidity < 40=>SendNotification(Humidity too low)
NormalOperation:temperature <= 30 && humidity >= 40=>LogInfo(System normal)
";
var processor = new LogicFlowBuilder()
.WithRuleLoader(new StringLogicRuleLoader(rulesString))
.Build();
var context = new ContextData();
context.AddFact("temperature", 35);
context.AddFact("humidity", 38);
processor.ExecuteLogicRules(context);
var processor = new LogicFlowBuilder()
.WithRuleLoader(new FileLogicRuleLoader("rules.txt"))
.Build();
RuleName:condition=>action
Simple comparison:
HighTemp:temperature > 30=>SendAlert(Too hot)
Logical AND:
Comfortable:temperature >= 20 && temperature <= 26=>LogInfo(Comfortable)
Logical OR:
Alert:temperature > 35 || humidity < 20=>SendAlert(Critical condition)
Variable substitution:
Status:battery < 20=>SendNotification(Battery at {battery}%)
SendAlert(message) - Send alertSendNotification(message) - Send notificationLogWarning(message) - Log warningLogInfo(message) - Log informationLogError(message) - Log errorpublic class MyActionHandler : DefaultActionHandler
{
protected override void SendAlert(string message)
{
// Send to your alert system
MyAlertSystem.Send(message);
}
}
var processor = new LogicFlowBuilder()
.WithActionHandler(new MyActionHandler())
.Build();
var rule1 = new LogicRule("Rule1", "value > 10", "LogInfo(Rule1)");
rule1.Priority = 1;
var rule2 = new LogicRule("Rule2", "value > 5", "LogInfo(Rule2)");
rule2.Priority = 2;
processor.AddLogicRule(rule1);
processor.AddLogicRule(rule2);
// Rule1 executes before Rule2
var processor = new LogicFlowBuilder().Build();
processor.RuleExecutionError += (sender, e) =>
{
Console.WriteLine($"Error in rule {e.Rule.Name}: {e.Exception.Message}");
};
processor.RuleParseError += (sender, e) =>
{
Console.WriteLine($"Parse error: {e.RuleString} - {e.Exception.Message}");
};
This project has adopted the Contributor Covenant Code of Conduct. For more information see the Code of Conduct FAQ.
MIT License - see LICENSE.txt for details
Contributions are welcome! Please read our Contributing Guide for details on how to get started.