DotNetRuleEngine 4.0.7

dotnet add package DotNetRuleEngine --version 4.0.7
NuGet\Install-Package DotNetRuleEngine -Version 4.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetRuleEngine" Version="4.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetRuleEngine --version 4.0.7
#r "nuget: DotNetRuleEngine, 4.0.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
4.0.7 25,828 4/12/2019
4.0.6 772 4/12/2019
4.0.3 1,044 1/29/2019
4.0.1 4,269 8/24/2018

Added additional Rule/RuleAsync methods to add nested rules.

See updated usage in documentation https://github.com/ayayalar/DotNetRuleEngine/wiki/Nesting-Rules