Skip to main content
Install the ZEN Engine and evaluate your first decision in C#.

Installation

Basic usage

Loader

The loader pattern enables dynamic decision loading from any storage backend. Implement the ZenDecisionLoaderCallback interface with a Task<JsonBuffer?> Load(string key) method. Use ConcurrentDictionary to cache decisions for optimal performance.

File system

AWS S3

Azure Blob Storage

Google Cloud Storage

Async evaluation

Evaluation methods return Task for native async/await integration:

Error handling

Tracing

Enable tracing to inspect decision execution:

Expression utilities

Evaluate ZEN expressions outside of a decision context:

Custom nodes

Extend the engine with custom logic by implementing ZenCustomNodeCallback:

Performance note

The C# bindings use UniFFI with P/Invoke for interoperability with the native Rust engine. This introduces some overhead compared to native Rust. Native libraries are bundled for Windows (x64), macOS (x64/ARM), and Linux (x64/ARM).

Best practices

Use using for resource management. ZenEngine, ZenDecision, and ZenExpression implement IDisposable to release native resources.
Initialize the engine once. Create a single ZenEngine instance at application startup and reuse it for all evaluations. Implement a loader for dynamic decisions. The loader pattern centralizes decision loading logic and enables caching with ConcurrentDictionary. Use Task.WhenAll for parallel evaluation. Evaluate multiple decisions concurrently with async/await.