SrgsDocument.Rules Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Sınıfı için SrgsDocument şu anda tanımlanmış kurallar koleksiyonunu alır.
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
Özellik Değeri
Nesne için SrgsDocument tanımlanan kuralları döndürür.
Örnekler
Aşağıdaki örnek, "Dünya Kupası'nı kazanan bir ulus" ifadesini ve ardından Dünya Kupası'nı kazanan bir ülkenin/bölgenin adını tanıyan bir dil bilgisi oluşturur. Örnek bir SrgsDocument nesnesi oluşturur ve ardından adlı winnerRule
bir genel kural oluşturur. kurala winnerRule
bir dize ekledikten sonra örnek, her biri ülke/bölge listesini içeren iki kural daha (ruleEurope
ve ruleSAmerica
) oluşturur.
Add yöntemi kullanılarak örnek, üç kuralın (winnerRule
, ruleEurope
ve ruleSAmerica
) tümünü özelliğinin RulesSrgsDocumentöğesine ekler.
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;
}
Açıklamalar
özelliğindeki Rules yöntemini kullanarak Add öğesine SrgsRulesCollection nesneleri ekleyebilirsinizSrgsRule. Bir SrgsDocument nesneyi başlatır ve bağımsız değişken olarak bir SrgsRule nesne belirtirseniz, SrgsRule için öğesine otomatik olarak eklenir SrgsRulesCollectionSrgsDocument.