Sdílet prostřednictvím


ISmartTagExtension.Recognize – metoda

Prohledá text v buňce rozpoznaný termínů.

Obor názvů:  Microsoft.Office.Tools.Excel
Sestavení:  Microsoft.Office.Tools.Excel (v Microsoft.Office.Tools.Excel.dll)

Syntaxe

'Deklarace
Sub Recognize ( _
    text As String, _
    site As ISmartTagRecognizerSite, _
    tokenList As ISmartTagTokenList, _
    context As SmartTagRecognizeContext _
)
void Recognize(
    string text,
    ISmartTagRecognizerSite site,
    ISmartTagTokenList tokenList,
    SmartTagRecognizeContext context
)

Parametry

  • site
    Typ: Microsoft.Office.Interop.SmartTag.ISmartTagRecognizerSite
    Umístění textu v dokumentu nebo sešitu.
  • tokenList
    Typ: Microsoft.Office.Interop.SmartTag.ISmartTagTokenList
    Podmínky rozdělené seznam tokenů rozpoznán text vyhledat.

Poznámky

Tato metoda volá Visual Studio Tools for Office runtime Hledat text rozpoznaný podmínky. Pokud chcete zahrnout vlastní vyhledávací algoritmy spouštění kromě standardní rozpoznávání implementujte tuto metoda .

Příklady

Následující příklad kódu ukazuje, jak implementovat Recognize metody. Tato implementace porovnává jednotlivé inteligentní značky termín obsah buňky v listaplikace Excel systém Microsoft Office . Pokud je nalezen termín inteligentních značek v buňce, kód přidá vlastní inteligentní značka vlastnost inteligentní značky a pak zavolá PersistTag metoda rozpoznávání inteligentních značek. Tento příklad předpokládá, že jste přidali odkaz na Microsoft.Office.Interop.SmartTag z .NET kartě Přidat odkaz dialogové okno. Příklad kódu je součástí větší příklad stanovené ISmartTagExtension rozhraní.

Private Sub Recognize(ByVal text As String,
    ByVal site As ISmartTagRecognizerSite,
    ByVal tokenList As ISmartTagTokenList,
    ByVal context As SmartTagRecognizeContext) Implements ISmartTagExtension.Recognize

    For Each term As String In smartTagDemo.Terms
        ' Search the text for the current smart tag term.
        Dim index As Integer = text.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.ToString())

            ' Attach the smart tag to the term in the document
            context.PersistTag(index, term.Length, propertyBag)

            ' Increment the index and then find the next instance of the smart tag term.
            index += term.Length
            index = text.IndexOf(term, index)
        End While
    Next
End Sub
void ISmartTagExtension.Recognize(string text, ISmartTagRecognizerSite site, ISmartTagTokenList tokenList, 
    SmartTagRecognizeContext context)
{

    foreach (string term in smartTagDemo.Terms)
    {
        // Search the text for the current smart tag term.
        int index = text.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
            context.PersistTag(index, term.Length, propertyBag);

            // Increment the index and then find the next instance of the smart tag term.
            index += term.Length;
            index = text.IndexOf(term, index);
        }
    }
}

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

ISmartTagExtension Rozhraní

Microsoft.Office.Tools.Excel – obor názvů