SrgsText-Klasse
Assembly: System.Speech (in system.speech.dll)
In the following example, the SRGS XML one-of element is created by the C# code that follows. Small, Medium and Large are the Text contents of the corresponding item elements in the XML code fragment.
When the SrgsItem object is constructed with a System.String parameter, a SrgsText object is created with its Text property initialized to the value of that parameter. The SrgsItem object is then added to the Elements collection on the SrgsItem object. The following C# example shows how the Text property on the original SrgsItem objects can be changed to the values shown in the XML fragment.
<!-- SRGS XML Fragment -->
<one-of>
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</one-of>
//C# fragment
SrgsDocument document = new SrgsDocument();
SrgsItem smallItem = new SrgsItem("Large");
SrgsItem mediumItem = new SrgsItem("Larger");
SrgsItem largeItem = new SrgsItem("Largest");
SrgsText textOfItem = null;
if (smallItem.Elements[0] is SrgsText)
{
textOfItem = smallItem.Elements[0] as SrgsText;
textOfItem.Text = "Small";
}
if (mediumItem.Elements[0] is SrgsText)
{
textOfItem = mediumItem.Elements[0] as SrgsText;
textOfItem.Text = "Medium";
}
if (largeItem.Elements[0] is SrgsText)
{
textOfItem = largeItem.Elements[0] as SrgsText;
textOfItem.Text = "Large";
}
SrgsOneOf oneOf = new SrgsOneOf(smallItem, mediumItem, largeItem);
SrgsRule rule = new SrgsRule("Sizes", oneOf);
document.Rules.Add(rule);
document.Root = rule;
string srgsDocumentFile = Path.Combine(Path.GetTempPath(), "srgsDocumentFile.xml");
XmlWriter writer = XmlWriter.Create(srgsDocumentFile);
document.WriteSrgs(writer);
writer.Close();
System.MarshalByRefObject
System.Speech.Recognition.SrgsGrammar.SrgsElement
System.Speech.Recognition.SrgsGrammar.SrgsText
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.