Skip to content

C# code

C# runs through .NET compiled to WebAssembly, with the Roslyn scripting engine. The runtime is embedded in Restorm: no .NET SDK is required on your machine.

SymbolRole
inputThe value received on the input port
varsA dictionary of the run variables
Console.Write / Console.WriteLineWrite to the execution log
The final expressionIts value leaves on the result port

The code is C# script (Roslyn style): no enclosing class and no Main to write, the statements are at the top level, and the final expression is the result.

using System.Linq;
using System.Text.Json;
var doc = JsonDocument.Parse(input.ToString());
var commandes = doc.RootElement.GetProperty("commandes").EnumerateArray();
var payees = commandes
.Where(c => c.GetProperty("statut").GetString() == "payee")
.ToList();
var total = payees.Sum(c => c.GetProperty("montant").GetDouble());
Console.WriteLine($"{payees.Count} commandes payées, total {total}");
new { nombre = payees.Count, total }

.NET’s base class library: System.Linq, System.Text.Json, System.Text.RegularExpressions, System.Security.Cryptography, System.Collections.Generic

This is the language to pick when you want to reuse business logic already written in C#, or when your team is more comfortable with it — not when you need to call something.