Working with RuleSets

  • Updated

Prerequisites: A valid RuleApplicationDef and EntityDef
Namespaces: InRule.Repository
Classes:   RuleApplicationDef, EntityDef, RuleSetDef
References: InRule.Repository.dll
See Also: Dynamically Generating a Rule Application Schema

The following code samples demonstrate how to retrieve and work with RuleSets for authoring purposes.

Get a list of RuleSets from an EntityDef
// This will return all top level RuleSets off of an Entity
RuleSetDef[] ruleSets = entityDef.GetRuleSets();

Get a list of all RuleSets from an EntityDef
// This will return all RuleSets off of an Entity, including RuleSets that are under Rule Folders
RuleSetDef[] ruleSets = entityDef.GetAllRuleSets();

Get a specific RuleSet by name from an EntityDef
// This will return a single RuleSetDef
RuleSetDef ruleSetDef = entityDef.GetRuleSet("MyRuleSet");

Get a list of independent RuleSets
// This will return a collection of independent RuleSets
RuleSetDefBaseCollection indRuleSets = ruleAppDef.RuleSets;

Get a specific independent RuleSet
// This will return a collection of independent RuleSets       
RuleSetDef indRuleSet = ruleAppDef.GetRuleSet("MyIndRuleSet");

Enable/Disable a RuleSet
// This will turn off the RuleSet, making it unavailable at runtime
// A disabled RuleSet cannot be turned on at runtime
ruleSetDef.IsActive = false;

Set Default Activation of a RuleSet
// This will turn off the default activation for the RuleSet
// A RuleSet that is enabled, can be activated or deactivated at runtime via rules or the SDK
ruleSetDef.DefaultActivation = false;

Set RuleSet Run Mode
// This will set the run mode to sequential
ruleSetDef.RunMode = RuleSetRunMode.Sequential;

Set RuleSet Fire Mode
// This will set the fire mode to explicit
ruleSetDef.FireMode = RuleSetFireMode.Explicit;

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.