Method RegisterValueFunction
- Namespace
- RuleWright.Execution
- Assembly
- RuleWright.Execution.dll
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.
public RuleWrightBuilder RegisterValueFunction(string name, Func<object?[], object?> function)
Parameters
namestringThe case-sensitive function name used in rule JSON.
functionFunc<object[], object>The value implementation.
Returns
Exceptions
- ArgumentException
nameis null/empty or already registered.- ArgumentNullException
functionis null.
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.
public RuleWrightBuilder RegisterValueFunction(IRuleValueFunction function)
Parameters
functionIRuleValueFunctionThe 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.