Namespaces: InRule.Repository, InRule.Repository.RuleElements, InRule.Authoring.BusinessLanguage,
InRule.Authoring.Controls, InRule.Authoring.Editors, InRule.Authoring.Editors.Controls
Classes: RuleApplicationDef, LanguageRuleDef, BusinessLanguageEditor, 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 business language 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
appropriate)
ControlFactory controlFactory = new ControlFactory();
// Load ruleapplicationdef
RuleApplicationDef ruleAppDef = RuleApplicationDef.Load(@"c:\work\mortgagecalculator.ruleapp")
// Load the rule application into the control factory
controlFactory.OpenRuleApplication(ruleAppDef);
// Get the entity
EntityDef entityDef = ruleAppDef.Entities["Mortgage"];
// Get the language rule to edit
LanguageRuleDef ruleDef =
(LanguageRuleDef)entityDef.GetRuleSet("PaymentRules").Rules["CalcPaymentSummary"];
// Get the business language editor and load into ContentControl
var control = controlFactory.CreateBusinessLanguageEditor(ruleDef);
Saving the changes
// Get the control from the form
if (control is BusinessLanguageEditor)
{
// Save the changes back to the rule application
control.Save();
}
// Dispose of the control if it implements IDisposable
if (control is IDisposable)
{
control.Dispose();
}
// Save the rule application back to the file system (this can also be saved to the Catalog)
ruleAppDef.SaveToFile(@"c:\work\mortgagecalculator.ruleapp");
Comments
0 comments
Please sign in to leave a comment.