Removing Templates in the Language Editor

  • Updated

Prerequisites: A valid RuleSession, A valid Entity
Namespaces: InRule.Repository, InRule.Repository.Vocabulary, InRule.Repository.Templates
Classes:   RuleApplicationDef, TemplateDef
See Also: Embedding the Language Rule Editor
References: InRule.Repository.dll

The following example demonstrates how to remove Templates from the Business Language Editor.  This code must run before the Populate method for the Business Language Editor is called.

Removing built in InRule Templates

// Create a new VocabularyDef if Vocabulary is null
if (ruleAppDef.Vocabulary == null)
{
 ruleAppDef.Vocabulary = new VocabularyDef();
}

// Remove the "Minus" template by adding a TemplateAvailabilitySettings and setting availability to Exclude
ruleAppDef.Vocabulary.TemplateAvailabilitySettings.Add(TemplateLiterals.TemplateGuids.Minus,
 InRule.Repository.Vocabulary.TemplateAvailability.Exclude);

Removing Rule Templates

// Make sure the Vocabulary is not null
if (ruleAppDef.Vocabulary == null)
{
  // Create a new VocabularyDef if null
   ruleAppDef.Vocabulary = new VocabularyDef();
}
// Get rule template by name (Note: this is not the same as the Display Name)
TemplateDef templateDef = (TemplateDef)ruleAppDef.Vocabulary.Templates["ExpressionTemplateDef1"];

// Remove the template using it's GUID
ruleAppDef.Vocabulary.TemplateAvailabilitySettings.Add(templateDef.Guid,
  TemplateAvailability.Exclude);

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.