SmartTagRecognizeContext.PersistTag – metoda
Ukládá informace o inteligentních značek.
Obor názvů: Microsoft.Office.Tools.Excel
Sestavení: Microsoft.Office.Tools.Excel (v Microsoft.Office.Tools.Excel.dll)
Syntaxe
'Deklarace
Sub PersistTag ( _
propertyBag As ISmartTagProperties _
)
void PersistTag(
ISmartTagProperties propertyBag
)
Parametry
- propertyBag
Typ: Microsoft.Office.Interop.SmartTag.ISmartTagProperties
Balík vlastnost obsahující dvojice klíče a hodnoty pro token.Může být nullodkaz Null (Nothing v jazyce Visual Basic).
Výjimky
Výjimka | Podmínka |
---|---|
InvalidOperationException | PersistTagnebyla volána z Recognize metody. |
Poznámky
Volání PersistTag z implementace Recognize Metoda označuje, že byl nalezen inteligentní značky v textu. Použít propertyBag parametr potvrdit všechny vlastní vlastnosti inteligentní značky. Pomocí těchto vlastností lze přizpůsobit akce vybrané položka v zástupce nabídka inteligentní značky.
Příklady
Následující příklad kódu ukazuje, jak volat PersistTag z implementace Recognize metody. Tato implementace porovná každý pojem inteligentní značka obsahu buňky. Pro každou inteligentní značku podmínku v buňce kód přidá vlastní inteligentní značky vlastnost a potom použije 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
' Determine whether each smart tag term exists in the document text.
Dim Term As String
For Each Term In smartTagDemo.Terms
' Search the cell text for the first instance of
' the current smart tag term.
Dim index As Integer = context.CellText.IndexOf(Term, 0)
If (index >= 0) Then
' 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.
context.PersistTag(propertyBag)
' This implementation only finds the first instance
' of a smart tag term in the cell.
Exit For
End If
Next
End Sub
void ISmartTagExtension.Recognize(string text, ISmartTagRecognizerSite site,
ISmartTagTokenList tokenList, SmartTagRecognizeContext context)
{
// Determine whether each smart tag term exists in the document text.
foreach (string term in smartTagDemo.Terms)
{
// Search the cell text for the first instance of the current smart tag term.
int index = context.CellText.IndexOf(term, 0);
if (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(propertyBag);
// This implementation only finds the first instance of a
// smart tag term in the cell.
break;
}
}
}
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.