SmartTag.ParagraphText Property (2007 System)
Gets the text from the paragraph that is sent to the recognizer.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Protected ReadOnly Property ParagraphText As String
'Usage
Dim value As String
value = Me.ParagraphText
protected string ParagraphText { get; }
protected:
property String^ ParagraphText {
String^ get ();
}
protected function get ParagraphText () : String
Property Value
Type: System.String
The text from the paragraph that is sent to the recognizer.
Remarks
This property is only intended to be used from the Recognize method.
Examples
The following code example demonstrates how to override the Recognize method within a class that derives from Microsoft.Office.Tools.Word.SmartTag. This implementation of Recognize compares each smart tag term to the contents of the paragraph. For each smart tag term in the paragraph, the code adds a custom smart tag property and then uses the PersistTag(Int32, Int32, ISmartTagProperties) method to recognize the smart tag. This example assumes that you have added a reference to Microsoft Smart Tags 2.0 Type Library from the COM tab of the Add Reference dialog box. This code example is part of a larger example provided for the SmartTag class.
Protected Overrides Sub Recognize(ByVal text As String, _
ByVal site As ISmartTagRecognizerSite, _
ByVal tokenList As ISmartTagTokenList)
' Determine whether each smart tag term exists in
' the document text.
Dim Term As String
For Each Term In Me.Terms
' Search the text for the current smart tag term.
Dim index As Integer = Me.ParagraphText.IndexOf(Term, 0)
While (index >= 0)
' Create a smart tag token and a property bag for the
' recognized term.
Dim propertyBag As ISmartTagProperties = _
site.GetNewPropertyBag()
' Write a new property value.
Dim key As String = "Key1"
propertyBag.Write(key, DateTime.Now)
' Attach the smart tag to the term in the document
Me.PersistTag(index, Term.Length, propertyBag)
' Increment the index and then find the next
' instance of the smart tag term.
index += Term.Length
index = ParagraphText.IndexOf(Term, index)
End While
Next
End Sub
protected override void Recognize(string text,
ISmartTagRecognizerSite site, ISmartTagTokenList tokenList)
{
foreach (string term in this.Terms)
{
// Search the text for the current smart tag term.
int index = this.ParagraphText.IndexOf(term, 0);
while (index >= 0)
{
// Create a smart tag token and a property bag for the
// recognized term.
ISmartTagProperties propertyBag =
site.GetNewPropertyBag();
// Write a new property value.
string key = "Key1";
propertyBag.Write(key, DateTime.Now.ToString());
// Attach the smart tag to the term in the document
this.PersistTag(index, term.Length, propertyBag);
// Increment the index and then find the next
// instance of the smart tag term.
index += term.Length;
index = ParagraphText.IndexOf(term, index);
}
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.