/desh.net

Parser, engine and tools for desh language in .net

Primary LanguageC#MIT LicenseMIT

desh.net

Appveyor NuGet License
Build status Test status NuGet Usage License

Why Desh?

Desh is a concise and readable language to describe business rules.

  • The language, parser and execution engine are generic and fit for any business domain.
  • The language is based on YAML, in other words, any Desh document is a valid YAML file.

How to use

Just install the Desh NuGet package:

PM> Install-Package desh

Craft a Desh document (YAML).

Let's take an example of an online travel agency. Customers want to know if they need a visa when traveling to another country.

The following Desh document describes business rules if a person needs a visa:

nationality:
  - NL:
      destination:
        - US: electronic_online_visa
        - UA:
            days_of_stay:
              - number_greater_than: 90
                decide: paper_visa
              - else: no_visa
  - UA:
      destination:
        - US: paper_visa
        - NL:
            biometric_passport:
              - yes: no_visa
              - no: paper_visa

Then we need customer's data:

nationality: NL
destination: US

Then we can feed this to Desh engine.

var desh = @"
nationality:
  - NL:
      destination:
        - US: electronic_online_visa
        - UA:
            days_of_stay:
              - number_greater_than: 90
                decide: paper_visa
              - else: no_visa
  - UA:
      destination:
        - US: paper_visa
        - NL:
            biometric_passport:
              - yes: no_visa
              - no: paper_visa
";
var customer =
	new Dictionary<string, Func<Task<string>>>
	{
		{ "nationality", () => Task.FromResult("NL") },
		{ "destination", () => Task.FromResult("US") }
	};
var facade = new DeshFacade();
var visaDecision = await facade.ParseAndMakeStringDecision(desh, customer);
Console.WriteLine($"Visa requirement: {visaDecision}");
// outputs "Visa requirement: electronic_online_visa"

What does the name stand for?

Desh is a phonetic abbreviation of Decision Expressions.