SrgsDocument.Rules 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 클래스에 대해 SrgsDocument 정의된 규칙의 컬렉션을 가져옵니다.
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
속성 값
개체에 대해 정의된 규칙을 반환합니다 SrgsDocument .
예제
다음 예제에서는 "월드컵에서 우승한 국가"라는 문구와 월드컵에서 우승한 국가/지역의 이름을 인식하는 문법을 만듭니다. 이 예제에서는 개체를 SrgsDocument 만든 다음 이라는 winnerRule공용 규칙을 만듭니다. 규칙에 winnerRule문자열을 추가한 후 이 예제에서는 각각 국가/지역 목록을 포함하는 두 개의 규칙(ruleEurope 및 ruleSAmerica)을 만듭니다. 이 예제에서는 이 메서드를 Add 사용하여 세 가지 규칙(winnerRule, ruleEurope및 ruleSAmerica)을 모두 의 속성에 Rules 추가합니다 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;
}
설명
속성의 SrgsRule 메서드 SrgsRulesCollection 를 사용하여 개체를 Add 추가할 Rules 수 있습니다. 개체를 SrgsDocument 초기화하고 개체를 SrgsRule 인수 SrgsRule 로 지정하면 해당 개체가 for에 SrgsRulesCollection자동으로 추가 SrgsDocument 됩니다.