Compartir vía


GrammarBuilder.Implicit Operator

Definition

Converts another type to a GrammarBuilder.

Overloads

Implicit(Choices to GrammarBuilder)

Converts a Choices object to a GrammarBuilder object.

Implicit(SemanticResultKey to GrammarBuilder)

Converts a SemanticResultKey object to a GrammarBuilder object.

Implicit(SemanticResultValue to GrammarBuilder)

Converts a SemanticResultValue object to a GrammarBuilder object.

Implicit(String to GrammarBuilder)

Converts a string to a GrammarBuilder object.

Remarks

Implicit conversion creates a new instance of GrammarBuilder. You can cast each of the following classes to a GrammarBuilder.

Each of the implicit casts is equivalent to calling the constructor.

Implicit(Choices to GrammarBuilder)

Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs

Converts a Choices object to a GrammarBuilder object.

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

Parameters

choices
Choices

The set of alternatives to convert.

Returns

The converted Choices object.

Examples

The following example creates a speech recognition grammar that can recognize a response to a "yes" or "no" question. The implicit conversion operator is used in the construction of a SemanticResultValue object from a Choices object, in the construction of a Choices object from two SemanticResultValue objects, and in the construction of a Grammar object from a SemanticResultKey object.

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";

Remarks

Implicit conversion creates a new instance of GrammarBuilder. This conversion operator is equivalent to calling GrammarBuilder and specifying choices for the alternateChoices.

The equivalent method for this operator is GrammarBuilder.GrammarBuilder(Choices)

See also

Applies to

Implicit(SemanticResultKey to GrammarBuilder)

Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs

Converts a SemanticResultKey object to a GrammarBuilder object.

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

Parameters

semanticKey
SemanticResultKey

The semantic key to convert.

Returns

The converted SemanticResultKey object.

Examples

The following example creates a speech recognition grammar that can recognize a response to a "yes" or "no" question. The implicit conversion operator is used in the construction of a SemanticResultValue object from a Choices object, in the construction of a Choices object from two SemanticResultValue objects, and in the construction of a Grammar object from a SemanticResultKey object.

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";

Remarks

Implicit conversion creates a new instance of GrammarBuilder. This conversion operator is equivalent to calling GrammarBuilder and specifying semanticKey for the key.

The equivalent method for this operator is GrammarBuilder.GrammarBuilder(SemanticResultKey)

See also

Applies to

Implicit(SemanticResultValue to GrammarBuilder)

Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs

Converts a SemanticResultValue object to a GrammarBuilder object.

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

Parameters

semanticValue
SemanticResultValue

The SemanticResultValue object to convert.

Returns

The converted SemanticResultValue object.

Examples

The following example creates a speech recognition grammar that can recognize a response to a "yes" or "no" question. The implicit conversion operator is used in the construction of a SemanticResultValue object from a Choicesobject, in the construction of a Choices object from two SemanticResultValue objects, and in the construction of a Grammar object from a SemanticResultKey object.

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";

Remarks

Implicit conversion creates a new instance of GrammarBuilder. This conversion operator is equivalent to calling GrammarBuilder and specifying semanticValue for the value.

The equivalent method for this operator is GrammarBuilder.GrammarBuilder(SemanticResultValue)

See also

Applies to

Implicit(String to GrammarBuilder)

Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs
Source:
GrammarBuilder.cs

Converts a string to a GrammarBuilder object.

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

Parameters

phrase
String

The string to convert.

Returns

The converted string.

Examples

The following example uses GrammarBuilder and Choices objects to construct a grammar that can recognize either of the two phrases, "Make background colorChoice" or "Set background to colorChoice".

After creating a list of acceptable values for colorChoice using a Choices object, the example initializes two GrammarBuilder objects, makePhrase and setPhrase, using implicit conversion from string objects.

The example finally creates a Grammar object from a Choices object cast to a GrammarBuilder object.

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;
}

Remarks

Implicit conversion creates a new instance of GrammarBuilder. This conversion operator is equivalent to calling GrammarBuilder and specifying the same phrase.

The equivalent method for this operator is GrammarBuilder.GrammarBuilder(String)

See also

Applies to