Table of Contents

Class RuleWrightBuilder

Namespace
RuleWright.Execution
Assembly
RuleWright.Execution.dll

Fluent entry point for configuring and creating a RuleWrightEngine.

public sealed class RuleWrightBuilder
Inheritance
RuleWrightBuilder
Inherited Members

Examples

var engine = new RuleWrightBuilder()
    .UseJsonReader(new SystemTextJsonReader())
    .RegisterFunction("IsBusinessDay", (fieldValue, value) => ...)
    .Build();

Constructors

RuleWrightBuilder()

Properties

DefaultRegexTimeout

The default MatchesRegex match timeout: one second. A pattern with catastrophic backtracking runs against consumer-supplied fact data, so matching is bounded rather than able to pin a thread indefinitely; exceeding the bound raises RegexMatchTimeoutException.

Methods

Build()

Creates the engine. The builder can be reused afterwards; the engine takes a snapshot of the registered functions and actions.

RegisterAction(IRuleActionHandler)

Registers a custom action handler under its Name.

RegisterAction(string, Action<RuleActionContext>)

Registers a custom action type referenced from rule JSON as { "type": "...", "target": "...", "value": ... }. The delegate receives a RuleActionContext carrying the action's target, its already-evaluated value, the fact, and read/write access to the running outputs. It must be thread-safe.

RegisterFunction(IRuleFunction)

Registers a custom condition function implementation under its Name.

RegisterFunction(string, Func<object?, object?, bool>)

Registers a custom condition function referenced from JSON as { "operator": "custom", "name": "..." }. The delegate receives the resolved field value (or the whole fact when the leaf has no field) and the leaf's constant value. It is bound into compiled rules at compile time and must be thread-safe.

RegisterValueFunction(IRuleValueFunction)

Registers a custom value function implementation under its Name. A function that also implements IRuleValueFunctionMetadata with a RequiredOperandCount gets its calls arity-checked at LoadRuleSet.

RegisterValueFunction(string, Func<object?[], object?>)

Registers a custom value function referenced from a value expression as { "call": "...", "operands": [...] }. The delegate receives the evaluated operand values in document order. It is bound into compiled rules at compile time, must be thread-safe, and should be total — return null for argument shapes it does not understand, like the built-in expression operators do.

UseJsonReader(IRuleJsonReader)

Sets the JSON reader adapter used by LoadRuleSet(string). Required before loading JSON; engines built without one can still load domain RuleSet instances directly.

UseRegexTimeout(TimeSpan)

Sets the per-match time limit for the MatchesRegex operator, overriding DefaultRegexTimeout. Applies to both execution paths; a match that exceeds it raises RegexMatchTimeoutException rather than running unbounded.