Applying Rules

  • Updated

Prerequisites: A valid RuleSession
Namespaces: InRule.Runtime
Classes:   RuleSession, Entity, RuleException
See Also: Retrieving a Rule Application, Creating a RuleSession, Creating Entities, Handling Exceptions
References: InRule.Runtime.dll, InRule.Common.dll

Apply rules

try
{
     // Apply the rules.
    session.ApplyRules();
}
catch (RuleException ex)
{
     // Handle any rule engine exceptions here.
    Console.WriteLine(ex.ToString());
}

Note: This will execute all Auto RuleSets, calculations, constraints and classifications.

Execute explicit rulesets and rule flows

// Apply the CalculatePaymentSchedule from the mortgageEntity
mortgageEntity.ExecuteRuleSet("CaculatePaymentSchedule");

Notes:

Rule flows are executed using the same method and behave in the same manner as explicit rulesets.
Any auto rules are also be applied when applying an explicit ruleset or rule flow

Execute explicit rulesets that accept parameters

// Execute the ruleset passing in a list of parameters
mortgageEntity.ExecuteRuleSet("AddCharge", "Appraisal", 400.99);

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.