Dieser Artikel wurde noch nicht bewertet - Dieses Thema bewerten.

SrgsText-Klasse

Represents the Text content for the World Wide Web Consortium (W3C) Speech Recognition Grammar Specification (SRGS) elements.

Namespace: System.Speech.Recognition.SrgsGrammar
Assembly: System.Speech (in system.speech.dll)

[SerializableAttribute] 
public class SrgsText : SrgsElement
/** @attribute SerializableAttribute() */ 
public class SrgsText extends SrgsElement
SerializableAttribute 
public class SrgsText extends SrgsElement
Nicht zutreffend.

The text content is the text found within a set of SRGS element tags.

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.Object
   System.MarshalByRefObject
     System.Speech.Recognition.SrgsGrammar.SrgsElement
      System.Speech.Recognition.SrgsGrammar.SrgsText
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

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.

.NET Framework

Unterstützt in: 3.0
Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Microsoft führt eine Onlineumfrage durch, um Ihre Meinung zur MSDN-Website zu erfahren. Wenn Sie sich zur Teilnahme entscheiden, wird Ihnen die Onlineumfrage angezeigt, sobald Sie die MSDN-Website verlassen.

Möchten Sie an der Umfrage teilnehmen?
© 2013 Microsoft. Alle Rechte vorbehalten.