SrgsDocument.Rules Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém o conjunto de regras atualmente definidas para a SrgsDocument classe.
public:
property System::Speech::Recognition::SrgsGrammar::SrgsRulesCollection ^ Rules { System::Speech::Recognition::SrgsGrammar::SrgsRulesCollection ^ get(); };
public System.Speech.Recognition.SrgsGrammar.SrgsRulesCollection Rules { get; }
member this.Rules : System.Speech.Recognition.SrgsGrammar.SrgsRulesCollection
Public ReadOnly Property Rules As SrgsRulesCollection
Valor de Propriedade
Devolve as regras definidas para o SrgsDocument objeto.
Exemplos
O exemplo seguinte cria uma gramática que reconhece a frase "Uma nação que venceu a Taça do Mundo é" seguida do nome de um país/região que venceu a Taça do Mundo. O exemplo cria um SrgsDocument objeto e depois cria uma regra pública chamada winnerRule. Após adicionar uma cadeia à regra winnerRule, o exemplo cria mais duas regras (ruleEurope e ruleSAmerica), cada uma contendo uma lista de países/regiões. Usando o Add método, o exemplo adiciona as três regras (winnerRule, ruleEurope, e ruleSAmerica) à Rules propriedade do SrgsDocument.
public void WorldSoccerWinners ()
{
// Create an SrgsDocument, create a new rule
// and set its scope to public.
SrgsDocument document = new SrgsDocument();
SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;
// Add the introduction.
winnerRule.Elements.Add(new SrgsItem("A nation that has won the World Cup is: "));
// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"),
new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));
// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"),
new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));
// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem
(new SrgsRuleRef(ruleEurope))), new SrgsItem(new SrgsRuleRef(ruleSAmerica))}));
// Add all the rules to the document and make winnerRule
// the root rule of the document.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
document.Root = winnerRule;
}
Observações
Pode adicionar SrgsRule objetos ao SrgsRulesCollection usando o Add método na Rules propriedade. Se inicializar um SrgsDocument objeto e especificar um SrgsRule objeto como argumento, o SrgsRule é automaticamente adicionado ao SrgsRulesCollection para o SrgsDocument.