Share via


SrgsText クラス

定義

W3C (World Wide Web Consortium) Speech Recognition Grammar Specification (SRGS) Version 1.0 で定義されている文法要素のテキスト コンテンツを表します。

public ref class SrgsText : System::Speech::Recognition::SrgsGrammar::SrgsElement
[System.Serializable]
public class SrgsText : System.Speech.Recognition.SrgsGrammar.SrgsElement
[<System.Serializable>]
type SrgsText = class
    inherit SrgsElement
Public Class SrgsText
Inherits SrgsElement
継承
属性

次の C# コード例は、クラスを使用してオブジェクトのテキストコンテンツを変更する方法を示して SrgsText SrgsItem います。 この例では、オブジェクトの初期のテキスト値 SrgsItem ( LargeLarger 、および Largest ) を、、、およびにそれぞれ変更し Small Medium Large ます。

// Create SrgsItem objects and specify their text.  
SrgsItem smallItem = new SrgsItem("Large");  
SrgsItem mediumItem = new SrgsItem("Larger");  
SrgsItem largeItem = new SrgsItem("Largest");  

SrgsText textOfItem = null;  

//  Change the text of smallItem.  
if (smallItem.Elements[0] is SrgsText)  
{  
  textOfItem = smallItem.Elements[0] as SrgsText;  
  textOfItem.Text = "Small";  
}  

//  Change the text of mediumItem.  
if (mediumItem.Elements[0] is SrgsText)  
{  
  textOfItem = mediumItem.Elements[0] as SrgsText;  
  textOfItem.Text = "Medium";  
}  

// Change the text of largeItem.  
if (largeItem.Elements[0] is SrgsText)  
{  
  textOfItem = largeItem.Elements[0] as SrgsText;  
  textOfItem.Text = "Large";  
}  

// Create an SrgsOneOf object and add smallItem, mediumItem,   
// and largeItem as alternatives.  
SrgsOneOf itemSize = new SrgsOneOf(new SrgsItem[]   
  { smallItem, mediumItem, largeItem });  

// Create a new SrgsRule from the SrgsOneOf object, and specify its identifier.  
SrgsRule size = new SrgsRule("Sizes", itemSize);  

// Create an SrgsDocument object.  
// Add the SrgsRule object to the collection of rules and make it the root rule.  
SrgsDocument document = new SrgsDocument();   
document.Rules.Add(size);  
document.Root = size;  

// Write the SrgsDocument to an XML grammar file.  
string srgsDocumentFile = Path.Combine(Path.GetTempPath(), "srgsDocumentFile.xml");  
XmlWriter writer = XmlWriter.Create(srgsDocumentFile);  
document.WriteSrgs(writer);  
writer.Close();  

次に示すのは、オブジェクトの変更されたテキストが、 SrgsItem 出力 XML 文法ファイルの要素としてどのように表示されるかを示して item います。

<!-- SRGS XML Fragment -->  
<one-of>  
  <item>Small</item>  
  <item>Medium</item>  
  <item>Large</item>  
</one-of>  

注釈

クラスは、 SrgsText SRGS 要素タグのセット内で見つかったテキストを表します。 パラメーターを SrgsItem 使用してオブジェクトを構築すると String 、その SrgsText Text パラメーターの値に初期化されたプロパティを使用してオブジェクトが作成されます。 オブジェクトは、 Text オブジェクトのコレクションに追加され Elements SrgsItem ます。

コンストラクター

SrgsText()

SrgsText クラスの新しいインスタンスを初期化します。

SrgsText(String)

インスタンスのテキストを指定して、SrgsText クラスの新しいインスタンスを初期化します。

プロパティ

Text

SrgsText クラス インスタンスに含まれるテキストを取得または設定します。

メソッド

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
互換性のために残されています。

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
互換性のために残されています。

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください