Viya.RuleEngine 0.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Viya.RuleEngine --version 0.1.3                
NuGet\Install-Package Viya.RuleEngine -Version 0.1.3                
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="Viya.RuleEngine" Version="0.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Viya.RuleEngine --version 0.1.3                
#r "nuget: Viya.RuleEngine, 0.1.3"                
#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 Viya.RuleEngine as a Cake Addin
#addin nuget:?package=Viya.RuleEngine&version=0.1.3

// Install Viya.RuleEngine as a Cake Tool
#tool nuget:?package=Viya.RuleEngine&version=0.1.3                

RuleEngine

With RuleEngine you can write rules, which consist of an expression and assignment, to modify a object/model.

These rules can be defined in yaml or with typed C# objects.

Example

Provided the following input object

Name: Henk
Age: 15
Phone: 0612345678
Address:
  StreetName: Hoofdstraat
  StreetNumber: 25a
  City: Amsterdam
  PostalCode: 1234AA
WorkAddress: null # Same type/fields as Address

Replacing a single property

rules:
  - condition: Age < 16
    assignment:
      Age: 25

The condition Age < 16 evaluates to: true
Thus the Age property becomes: 25

Replacing multiple properties at once (merge)

rules:
  - condition: Phone.StartsWith("06")
    assignment:
      Phone: 0612341234
      Address:
        City: Hilversum

The condition Phone.StartsWith("06") evaluates to: true
Thus the Phone property becomes 0621341234 and Address.City becomes Hilversum

Copy-ing properties from the input object

rules:
  - condition: true
    assignment: # copy to child object (not null) 
      WorkAddress: input.Address

Here the condition is true
The result becomes:

Name: Henk
Age: 15
Phone: 0612345678
Address:
  StreetName: Hoofdstraat
  StreetNumber: 25a
  City: Amsterdam
  PostalCode: 1234AA
WorkAddress:
  StreetName: Hoofdstraat
  StreetNumber: 25a
  City: Amsterdam
  PostalCode: 1234AA

Finding the best tool for the job

Running a benchmark

dotnet run -c Release -p RuleEngine.Benchmark

Results:

Resources

All this was not possible without the following libraries:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.4.1 1,861 1/9/2023
0.4.0 333 1/9/2023
0.3.2 374 12/19/2022
0.3.1 447 12/19/2022
0.3.0 287 12/19/2022
0.2.0 317 12/15/2022
0.1.3 455 12/13/2022
0.1.2 295 12/13/2022
0.1.1 288 12/12/2022
0.1.0 281 12/12/2022