SrgsDocument.Rules Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene la raccolta di regole attualmente definite per la 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
Valore della proprietà
Restituisce le regole definite per l'oggetto SrgsDocument .
Esempio
Nell'esempio seguente viene creata una grammatica che riconosce la frase "Una nazione che ha vinto la Coppa del Mondo" seguita dal nome di un paese/area geografica che ha vinto la Coppa del Mondo. Nell'esempio viene creato un SrgsDocument oggetto e quindi viene creata una regola pubblica denominata winnerRule. Dopo aver aggiunto una stringa alla regola winnerRule, nell'esempio vengono create altre due regole (ruleEurope e ruleSAmerica), ognuna contenente un elenco di paesi/aree geografiche. Usando il Add metodo , nell'esempio vengono aggiunte tutte e tre le regole (winnerRule, ruleEuropee ruleSAmerica) alla Rules proprietà dell'oggetto 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;
}
Commenti
È possibile aggiungere SrgsRule oggetti a SrgsRulesCollection utilizzando il Add metodo sulla Rules proprietà . Se si inizializza un SrgsDocument oggetto e si specifica un SrgsRule oggetto come argomento, l'oggetto SrgsRule viene aggiunto automaticamente a SrgsRulesCollection per .SrgsDocument