| ILOG Rules for .NET User Guides > Rule Studio > Executing Rules > Presenting Objects to the Rule Engine |
Presenting Objects to the Rule Engine |
PREVIOUS NEXT |
The ILOG Rule Engine for .NET is represented by the RuleEngine class. Before executing the ruleset with RuleEngine.Execute you need to present the objects to which you want to apply the rules. You can do this in one of two ways: by adding objects to the working memory directly; or by using ruleset parameters in conjunction with a ruleflow. See Creating an Engine and Executing a Ruleset for an example of how to set parameter values.
The Assert method adds an (unnamed) object to working memory. If you pass a collection as a ruleset parameter you have a named object that you can dereference from within your rules. If your business logic requires significant pattern matching or inference, then the Assert API and the working memory of the RetePlus mode is recommended. Presenting objects in this way forces you into a stateful interaction with the engine. Error handling and/or failure recovery can become more complex in these cases.
For example:
[C#]
using ILOG.Rules; using CustomerBOM; // the business object model ... RuleEngine engine = new RuleEngine(); Person billy = new Person(); // the object of interest billy.name = "Billy"; engine.RuleSet = new CustomerRules(); // the rules to execute engine.Assert(billy); // add the object in working memory engine.Execute();
[Visual Basic]
Imports ILOG.Rules Imports CustomerBOM `the business object model ... Dim engine As New RuleEngine engine.RuleSet = New CustomerRules `the rules to execute Dim billy As New Customer `the object of interest billy.name = "Billy" engine.Assert(billy) `add the object in working memory engine.Execute()
| Note |
| Always set the ruleset before adding objects to the working memory. |
Creating an Engine and Executing a Ruleset | Retrieving Data and Events From the Engine | The RetePlus Mode
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |