通过


SrgsDocument.Root 属性

定义

获取或设置类的 SrgsDocument 根规则。

public:
 property System::Speech::Recognition::SrgsGrammar::SrgsRule ^ Root { System::Speech::Recognition::SrgsGrammar::SrgsRule ^ get(); void set(System::Speech::Recognition::SrgsGrammar::SrgsRule ^ value); };
public System.Speech.Recognition.SrgsGrammar.SrgsRule? Root { get; set; }
public System.Speech.Recognition.SrgsGrammar.SrgsRule Root { get; set; }
member this.Root : System.Speech.Recognition.SrgsGrammar.SrgsRule with get, set
Public Property Root As SrgsRule

属性值

返回指定为该 SrgsDocument规则的根规则。

示例

以下示例创建一个名为的规则,然后创建名为 <a0/> 的对象。 然后,该示例调用 Add 方法将规则添加到文档。 最后,该示例将文档 Root 的属性设置为 winnerRule,从而使它 root rule 成为对象定义的 SrgsDocument 语法。

SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;

SrgsDocument document = new SrgsDocument();

document.Rules.Add(winnerRule);
document.Root = winnerRule;

注解

对象 SrgsRule 必须已位于文档中 SrgsRulesCollection ,然后才能将其设置为 根规则

还可以通过使用SrgsRule对象作为构造函数的参数SrgsDocument来设置对象的根规则SrgsDocument

适用于

另请参阅