Udostępnij za pośrednictwem


GrammarBuilder.Implicit Operator

Definicja

Konwertuje inny typ na GrammarBuilder .

Przeciążenia

Implicit(Choices to GrammarBuilder)

Konwertuje Choices obiekt na GrammarBuilder obiekt.

Implicit(SemanticResultKey to GrammarBuilder)

Konwertuje SemanticResultKey obiekt na GrammarBuilder obiekt.

Implicit(SemanticResultValue to GrammarBuilder)

Konwertuje SemanticResultValue obiekt na GrammarBuilder obiekt.

Implicit(String to GrammarBuilder)

Konwertuje ciąg na GrammarBuilder obiekt.

Uwagi

Niejawna konwersja tworzy nowe wystąpienie GrammarBuilder . Każdą z następujących klas można rzutować na GrammarBuilder .

Wszystkie rzuty niejawne są równoważne wywołaniu konstruktora.

Implicit(Choices to GrammarBuilder)

Konwertuje Choices obiekt na GrammarBuilder obiekt.

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::Choices ^ choices);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.Choices choices);
static member op_Implicit : System.Speech.Recognition.Choices -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (choices As Choices) As GrammarBuilder

Parametry

choices
Choices

Zestaw alternatyw do przekonwertowania.

Zwraca

GrammarBuilder

Przekonwertowany Choices obiekt.

Przykłady

Poniższy przykład tworzy gramatykę rozpoznawania mowy, która może rozpoznać odpowiedź na pytanie "yes" lub "No". Operator niejawnej konwersji jest używany w konstruowaniu SemanticResultValue obiektu z Choices obiektu, w konstrukcji Choices obiektu z dwóch SemanticResultValue obiektów i w konstrukcji Grammar obiektu z SemanticResultKey obiektu.

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

Uwagi

Niejawna konwersja tworzy nowe wystąpienie GrammarBuilder . Ten operator konwersji jest odpowiednikiem wywołania GrammarBuilder i określenia choices dla alternateChoices .

Równoważna Metoda dla tego operatora to GrammarBuilder.GrammarBuilder(Choices)

Zobacz też

Dotyczy

Implicit(SemanticResultKey to GrammarBuilder)

Konwertuje SemanticResultKey obiekt na GrammarBuilder obiekt.

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::SemanticResultKey ^ semanticKey);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.SemanticResultKey semanticKey);
static member op_Implicit : System.Speech.Recognition.SemanticResultKey -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (semanticKey As SemanticResultKey) As GrammarBuilder

Parametry

semanticKey
SemanticResultKey

Klucz semantyczny do przekonwertowania.

Zwraca

GrammarBuilder

Przekonwertowany SemanticResultKey obiekt.

Przykłady

Poniższy przykład tworzy gramatykę rozpoznawania mowy, która może rozpoznać odpowiedź na pytanie "yes" lub "No". Operator niejawnej konwersji jest używany w konstruowaniu SemanticResultValue obiektu z Choices obiektu, w konstrukcji Choices obiektu z dwóch SemanticResultValue obiektów i w konstrukcji Grammar obiektu z SemanticResultKey obiektu.

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

Uwagi

Niejawna konwersja tworzy nowe wystąpienie GrammarBuilder . Ten operator konwersji jest odpowiednikiem wywołania GrammarBuilder i określenia semanticKey dla key .

Równoważna Metoda dla tego operatora to GrammarBuilder.GrammarBuilder(SemanticResultKey)

Zobacz też

Dotyczy

Implicit(SemanticResultValue to GrammarBuilder)

Konwertuje SemanticResultValue obiekt na GrammarBuilder obiekt.

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::SemanticResultValue ^ semanticValue);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.SemanticResultValue semanticValue);
static member op_Implicit : System.Speech.Recognition.SemanticResultValue -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (semanticValue As SemanticResultValue) As GrammarBuilder

Parametry

semanticValue
SemanticResultValue

SemanticResultValueObiekt do przekonwertowania.

Zwraca

GrammarBuilder

Przekonwertowany SemanticResultValue obiekt.

Przykłady

Poniższy przykład tworzy gramatykę rozpoznawania mowy, która może rozpoznać odpowiedź na pytanie "yes" lub "No". Operator niejawnej konwersji jest używany w konstruowaniu SemanticResultValue obiektu z Choices obiektu, w konstrukcji Choices obiektu z dwóch SemanticResultValue obiektów i w konstrukcji Grammar obiektu z SemanticResultKey obiektu.

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

Uwagi

Niejawna konwersja tworzy nowe wystąpienie GrammarBuilder . Ten operator konwersji jest odpowiednikiem wywołania GrammarBuilder i określenia semanticValue dla value .

Równoważna Metoda dla tego operatora to GrammarBuilder.GrammarBuilder(SemanticResultValue)

Zobacz też

Dotyczy

Implicit(String to GrammarBuilder)

Konwertuje ciąg na GrammarBuilder obiekt.

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::String ^ phrase);
public static implicit operator System.Speech.Recognition.GrammarBuilder (string phrase);
static member op_Implicit : string -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (phrase As String) As GrammarBuilder

Parametry

phrase
String

Ciąg do konwersji.

Zwraca

GrammarBuilder

Przekonwertowany ciąg.

Przykłady

Poniższy przykład używa GrammarBuilder i Choices obiektów do konstruowania gramatyki, która może rozpoznawać jedną z dwóch fraz, " colorChoice w tle" lub "Set Background to colorChoice".

Po utworzeniu listy akceptowalnych wartości dla colorChoice przy użyciu Choices obiektu, przykład inicjuje dwa GrammarBuilder obiekty makePhrase i setPhrase , przy użyciu niejawnej konwersji z obiektów String.

Przykład tworzy Grammar obiekt na podstawie Choices rzutowania obiektu na GrammarBuilder obiekt.

private Grammar CreateColorGrammar()  
{  

  // Create a set of color choices.  
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});  
  GrammarBuilder colorElement = new GrammarBuilder(colorChoice);  

  // Create grammar builders for the two versions of the phrase.  
  GrammarBuilder makePhrase = new GrammarBuilder("Make background");  
  makePhrase.Append(colorElement);  
  GrammarBuilder setPhrase = new GrammarBuilder("Set background to");  
  setPhrase.Append(colorElement);  

  // Create a Choices for the two alternative phrases, convert the Choices  
  // to a GrammarBuilder, and construct the Grammar object from the result.  
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});  
  Grammar grammar = new Grammar((GrammarBuilder)bothChoices);  
  grammar.Name = "backgroundColor";  
  return grammar;  
}  

Uwagi

Niejawna konwersja tworzy nowe wystąpienie GrammarBuilder . Ten operator konwersji jest odpowiednikiem wywołania GrammarBuilder i określenia tego samego phrase .

Równoważna Metoda dla tego operatora to GrammarBuilder.GrammarBuilder(String)

Zobacz też

Dotyczy