◷ Reading Time: 2 minutes
The glossary allows your rules to be defined and modeled with your own business language and terminologies. You can also check the Glossary API if you want to define them in pure XML rather than using FlexRule Designer.
Using Logic Files
If you are using a File System directly in order to load your logic (i.e., Natural language, Decision table), then during the creation of an engine using Runtime Engine, you should provide the base address to load the glossary files as well.
var person = new Person("arash", 10, DecisionAgeTests.Gender.Male); var ruleFile = "AgeTitle_ExternalGlossary.xml"; var logicFullPath = System.IO.GetFullPath(ruleFile); // This returns the full path address to the logic document var baseFolder = System.IO.Path.GetDirectoryName(logicFullPath); // This returns the full base path to where all other logic documents are located // creating an engine and providing location for glossary var engine = RuntimeEngine.FromXml(System.IO.File.ReadAllBytes(logicPath), baseFolder); engine.Run(person);
Note, as shown in line #7 above, the base folder baseFolder to glossary must be provided. This allows the engine to resolve the dependencies to glossaries from the OS file system. The baseFolder is the full path address where all of your logic documents are located.
If you use RuleSet to create an instance of Runtime Engine then you should provide the Glossary object. You can load a glossary with Glossary.Load from a ruleset.
var rs = RuleSet.HierarchicalRuleSet(); rs.AddModel("glossaries", LoadAdapterUtility.LoadModel("AgeTitleGlossary.xml")); rs.AddModel("rules", LoadAdapterUtility.LoadModel("AgeTitle_ExternalGlossary-ruleset.xml")); Glossary glossary = Glossary.Load(rs, "ruleset://glossaries/person"); var person = new DecisionAgeTests.Person("arash", 10, DecisionAgeTests.Gender.Male); var engine = RuntimeEngine.FromRuleSet(rs,"ruleset://rules/person growing state",glossary); engine.Run(person);