public SpeechGrammar UpdateXML(SpeechGrammar grammar, String bodyXML) { if (grammar == null) { return(null); } // Include BODY to XML var name = grammar.Name; var rule = "rule" + Char.ToUpper(name[0]) + name.Substring(1); var xml = "\n<grammar version=\"1.0\" xml:lang=\"" + ConfigManager.GetInstance().Find("bot.language", "fr-FR") + "\" mode=\"voice\" root=\"" + name + "\" xmlns=\"http://www.w3.org/2001/06/grammar\" tag-format=\"semantics/1.0\">"; xml += "\n<rule id=\"" + name + "\" scope=\"public\">"; xml += "\n<tag>out.action=new Object(); </tag>"; xml += bodyXML; xml += "\n</rule>"; xml += "\n</grammar>"; // Load Grammar LoadXML(grammar, xml); grammar.LastModified = DateTime.Now; // Add to cache if (!Cache.ContainsKey(name)) { Cache[name] = grammar; } // Reload the XML of the Grammar foreach (SpeechEngine engine in SpeechManager.GetInstance().GetEngines()) { engine.Load(name, grammar.Build()); } return(grammar); }
public SpeechGrammar UpdateXML(SpeechGrammar grammar, String bodyXML) { if (grammar == null) { return null; } // Include BODY to XML var name = grammar.Name; var rule = "rule" + Char.ToUpper(name[0]) + name.Substring(1); var xml = "\n<grammar version=\"1.0\" xml:lang=\"" + ConfigManager.GetInstance().Find("bot.language", "fr-FR") + "\" mode=\"voice\" root=\"" + name + "\" xmlns=\"http://www.w3.org/2001/06/grammar\" tag-format=\"semantics/1.0\">"; xml += "\n<rule id=\"" + name + "\" scope=\"public\">"; xml += "\n<tag>out.action=new Object(); </tag>"; xml += bodyXML; xml += "\n</rule>"; xml += "\n</grammar>"; // Load Grammar LoadXML(grammar, xml); grammar.LastModified = DateTime.Now; // Add to cache if (!Cache.ContainsKey(name)) { Cache[name] = grammar; } // Reload the XML of the Grammar foreach (SpeechEngine engine in SpeechManager.GetInstance().GetEngines()) { engine.Load(name, grammar.Build()); } return grammar; }