Method RegisterFunction
- Namespace
- RuleWright.Execution
- Assembly
- RuleWright.Execution.dll
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.
public RuleWrightBuilder RegisterFunction(string name, Func<object?, object?, bool> function)
Parameters
namestringThe case-sensitive function name used in rule JSON.
functionFunc<object, object, bool>The condition implementation.
Returns
Exceptions
- ArgumentException
nameis null/empty or already registered.- ArgumentNullException
functionis null.
RegisterFunction(IRuleFunction)
Registers a custom condition function implementation under its Name.
public RuleWrightBuilder RegisterFunction(IRuleFunction function)
Parameters
functionIRuleFunctionThe function; must expose a non-empty name and be thread-safe.
Returns
Exceptions
- ArgumentNullException
functionis null.- ArgumentException
The function's name is null/empty or already registered.