DotNetRuleEngine 4.0.7
dotnet add package DotNetRuleEngine --version 4.0.7
NuGet\Install-Package DotNetRuleEngine -Version 4.0.7
<PackageReference Include="DotNetRuleEngine" Version="4.0.7" />
paket add DotNetRuleEngine --version 4.0.7
#r "nuget: DotNetRuleEngine, 4.0.7"
// Install DotNetRuleEngine as a Cake Addin
#addin nuget:?package=DotNetRuleEngine&version=4.0.7
// Install DotNetRuleEngine as a Cake Tool
#tool nuget:?package=DotNetRuleEngine&version=4.0.7
DotNetRuleEngine allows you to write your code as series of rules to keep your code clean and structured. Supports both synchronous and asynchronous patterns and it adheres to S.O.L.I.D design principles.
A few reasons use DotNetRuleEngine
- Adheres to S.O.L.I.D
- Testable code.
- Encapsulates varying behavior. Such as business rules.
Get Started at: DotNetRuleEngine Wiki
Example
Create Rule(s)
Create a rule to update FreeShipping attribute if the amount is greater than $50.00
public class QualifiesForFreeShipping: Rule<Order>
{
public override IRuleResult Invoke()
{
// Order instance available through the model property.
if (Model.Total > 50.0m)
{
Model.FreeShipping = true;
}
return null;
}
}
Invoke Rule(s)
Order order = new Order { Id = 1, Total = 79.99 };
// Pass order instance to RuleEngine.
var ruleResults = RuleEngine<Order>.GetInstance(order)
.ApplyRules(new QualifiesForFreeShipping())
.Execute()
Model used as an example
public class Order
{
public int Id { get; set; }
public decimal Total { get; set; }
public bool FreeShipping { get; set; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net20 is compatible. net35 was computed. net40 was computed. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added additional Rule/RuleAsync methods to add nested rules.
See updated usage in documentation https://github.com/ayayalar/DotNetRuleEngine/wiki/Nesting-Rules