Skip to main content



Working with Advanced Definition Objects

Removing Templates in the Language Editor

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);

Determine FieldDef Dependencies

Prerequisites

A valid RuleRepositoryDefBase, A valid EvalNetwork

Namespaces

InRule.Repository , InRule.Repository.Infos

Classes

RuleApplicationDef, RuleRepositoryDefBase, DefUsageNetwork, FieldDef

References

InRule.Common.dll, InRule.Repository.dll


Determine FieldDef Dependencies

The following recursive method shows how to identify all FieldDef dependencies for a given RuleRepositoryDefBase object.

public static IEnumerable<DefUsage> GetDependentFieldDefs(RuleRepositoryDefBase def,
DefUsageNetwork network)
{
// Create collection of all usages by the given definition
var usages = network.GetDefUsages(def.Guid, true);

// Return list of dependencies
return usages;
}

Instantiate the DefUsageNetwork

The following code snippet demonstrates the proper way to create an instance of the DefUsageNetwork.

public static DefUsageNetwork GetDefUsageNetwork(RuleApplicationDef ruleAppDef)
{
return DefUsageNetwork.Create(ruleAppDef);
}