Applying Rules with an Activation Model

  • Updated

Prerequisites: A valid RuleSession and Entity
Namespaces: InRule.Runtime
Classes:   RuleSession, Entity
References: InRule.Runtime.dll, InRule.Common.dll

The following examples demonstrate how to control rule execution by Activating and Deactivating RuleSets through a variety of techniques.  The Activation should be set by calling one of the methods below and then rules can be applied as seen here.

Activate RuleSets by Name

// Activate ruleset by name
ruleSession.ActivateRuleSets("Entity1.RuleSet1");

Deactivate RuleSets by Name

// Deactivate ruleset by name
ruleSession.DeactivateRuleSets("Entity1.RuleSet1");

Activate RuleSets by Category

// Activate ruleset by category
ruleSession.ActivateRuleSetsByCategory("Category1");

Deactivate RuleSets by Category

// Deactivate ruleset by category
ruleSession.DeactivateRuleSetsByCategory("Category1");

Activate RuleSet by Name from an Entity

// Activate ruleset by name
entity.ActivateRuleSet("RuleSet1");

Deactivate RuleSet by Name from an Entity

// Deactivate ruleset by name
entity.DeactivateRuleSet("RuleSet1");

Reset RuleSet activations

// Reset rule activations
ruleSession.ResetAllRuleSetActivations();

Note: When calling ResetAllRuleSetActivations, the Activation status is set back to the original status at the time of authoring.

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.