The rule engine for .NET Application Programming Interface (API)

The runtime API of the rule engine for .NET is based on a number of documented interfaces that support the migration of a Rule Designer ruleset archive to a .NET ruleset DLL.

You can read the reference documentation for the rule engine for .NET by opening the class library C# API.

Runtime API overview

An engine definition is similar to a Rule Designer engine ruleset. Using an engine definition, you can access rules or tasks and create an executable engine.

An engine definition can be a rule engine definition or a ruleflow engine definition.

From a EngineDefinition object, you can try to downcast to a RuleEngineDefinition or RuleflowEngineDefinition object by using the as operator. For example:

RuleflowEngineDefinition = engineDefinition as RuleflowEngineDefinition;
Accessing rules

In the rule engine for .NET, a rule is represented as a Rule instance. Use the Rule interface to retrieve information about a particular rule. Rule objects are always attached to a RuleEngineDefinition object.

Accessing tasks

In the rule engine for .NET, a task is represented as a Task instance. Use the Task interface to retrieve information about a particular task. Task objects are always attached to an EngineDefinition object. Rule tasks are instances of the RuleTask interface. From rule tasks, you can access the rule engine definition, and hence, the definition of the rules that are used in that rule task.

Main classes

The rule engine for .NET runtime API is based on the following classes:

Mappings

The following tables show the mapping from IlrContext members to their equivalents in the rule engine for .NET API.

Table 1. Main API
Java™ rule engine API rule engine for .NET API
fireRule() ExecuteFirstRule(); StepOneRule()
fireAllRule() Execute(EngineInput)
fireRules(Rule[]) No equivalent method.
execute() Execute(EngineInput)
invokeFunction(String,Object[]) No equivalent method.
executeMain(Object) No equivalent method.
executeMain(String,Object) No equivalent method.
Table 2. Working Memory API
Java rule engine API rule engine for .NET API
insert(Object) Engine.Insert(Object)

Before execution, use the EngineInput.WorkingMemory property.

During execution, use the method Engine.Insert(Object).

retract(Object) Engine.Retract(Object)
update(Object) Engine.Update(Object)
update(Object, boolean)

Engine.Update(Object)

See Update refresh

updateContext() Engine.UpdateContext()
retractAll(boolean) Engine.RetractAll()
getObjects(Class) No equivalent method.
enumerateObjects() No equivalent method

During execution, there are no equivalent methods. You can use the EngineOutput.WorkingMemory property after execution.

Table 3. Event and logical API
Java rule engine API rule engine for .NET API
time() No equivalent method.
nextTime() No equivalent method.
nextTime(long) No equivalent method.
setTime(long) No equivalent method.
Table 4. Ruleflow API
Java rule engine API rule engine for .NET API
setMainTask(String)

RuleflowEngineInput.MainTask = <string>.

This step comes before the Execute method is called.

getMainTask() No equivalent method.
isUsingFlow() Returns true if the current engine is an instance of RuleflowEngine.
getRuleTaskRunner(Task) No equivalent method.
getRuleTaskRunner(CompiledTask) No equivalent method.
endCurrentTask(CompiledTask) No equivalent method.
executeTask() No equivalent method.
getTask(String) No equivalent method.
getCurrentTask() No equivalent method.
resetRuleflow() No equivalent method.
isTaskCompleted() No equivalent method.
Table 5. Miscellaneous API
Java rule engine API rule engine for .NET API
getRuleset() Engine.Definition
reset() Engine.Reset()
end() No equivalent method.
send(Object) No equivalent method.
send(String,Object) No equivalent method.
setParameters(ParameterMap) No equivalent method.
setParameterValue(String, Object) EngineInput[String] = Object
getParameterValue() EngineData[String] or EngineOutput[String]
getReturnValues() EngineData.GetOut()
note(String) Engine.Note(String)
out Console.Out