SrgsDocument.Rules 속성

정의

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

속성 값

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 자동으로 추가 됩니다는 SrgsRulesCollection 에 대 한는 SrgsDocument합니다.

적용 대상

추가 정보