Embedding the Condition Editor

  • Updated

Namespaces: InRule.Repository, InRule.Repository.RuleElements, InRule.Authoring.BusinessLanguage,
InRule.Authoring.Controls, InRule.Authoring.Editors, InRule.Authoring.Editors.Controls
Classes:   RuleApplicationDef, ControlFactory
See Also: Opening a RuleApplicationDef for Authoring, WinForm Considerations
References: InRule.Repository.dll, InRule.Authoring.dll, InRule.Authoring.BusinessLanguage.dll, InRule.Authoring.Editors.dll, InRule.Common.dll

Loading the condition editor into a ContentControl

The following code works in WPF.  Loading the control in this manner will only load the control, the Name and Enabled fields will not be present.  To embed the entire control see here.

// Create an instance of the control factory (consider keeping this at form level to reuse where
ControlFactory controlFactory = new ControlFactory();

// Load ruleapplicationdef
RuleApplicationDef ruleAppDef = RuleApplicationDef.Load(@"c:\work\mortgagecalculator.ruleapp");

// Get the entity
EntityDef entityDef = ruleAppDef.Entities["Mortgage"];

// Get the decision table to edit
SimpleRuleDef simpleRuleDef = (SimpleRuleDef)entityDef.GetRuleSet("CalcPaymentSchedule").Rules["IfLoanIsValid"];

// Load condition editor into content control, defaulting to business language mode (false for last parameter will load in syntax mode)
var control  = controlFactory.CreateConditionEditor(simpleRuleDef,

Saving the changes

if (control != null)
 // Call save values

 // If user is in syntax mode, then we need to manually save the changes back to the rule
 if (!control.UseLanguageExpression)
         // Get the rule from the editor
         var contextDef = (SimpleRuleDef)control.ContextDef;

         // Update the definition object
         contextDef.ConditionExpression = control.Expression;

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.