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.
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 rule engine definition, an instance of RuleEngineDefinition, you can retrieve rules.
From a ruleflow engine definition, an instance of RuleflowEngineDefinition, you can retrieve tasks.
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;
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.
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.
The rule engine for .NET runtime API is based on the following classes:
Engine: This interface is similar to the Rule Designer IlrContext class. Use it to create engine objects. You run an engine by calling its Execute method. This method takes an EngineInput object and returns an EngineOutput object. The rule engine uses a working memory and an agenda to contain and manipulate application objects. The working memory contains references to the application objects and the agenda lists and orders the rule instances that are eligible to be executed.
RuleEngineDefinition: This interface is similar to the Rule Designer IlrRuleset class.
Use it to retrieve an engine description that contains the tasks for a ruleflow engine and create a new engine instance, an Engine object. A rule engine definition is similar to a Rule Designer ruleset. Using an engine definition, you can access rules or tasks and create an executable.
EngineInput: The input for an engine execution contains the ruleset parameter values, represented by instances of the EngineData interface (done in Rule Designer by the IlrContext class) and the initial working memory. The EngineInput class is the only one you can use to set ruleset parameters.
EngineData: This interface contains accessors to retrieve parameter values. These accessors are similar to the getParameterValue methods of the IlrContext class. EngineData instances store the actual data while EngineInput and EngineOutput instances provides access to it.
EngineOutput: The output of an engine execution contains the parameter values, represented by EngineData objects, and the resulting working memory.
Rule: Rules are represented as Rule instances. Use the Rule class to get information about a particular rule. A Rule object is always attached to a RuleEngineDefinition object.
Task: Tasks are represented as Task instances. Use the Task class to retrieve information about a particular task. Task objects are always attached to aTaskEngineDefinition object.
The following tables show the mapping from IlrContext members to their equivalents in the rule engine for .NET 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. |
| 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.
| 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. |
| 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. |
| 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 |