مشاركة عبر


SmartTagRecognizeContext.PersistTag أسلوب

قم بتخزين معلومات حول علامة ذكية.

مساحة الاسم:  Microsoft.Office.Tools.Word
التجميع:  Microsoft.Office.Tools.Word (في Microsoft.Office.Tools.Word.dll)

بناء الجملة

'إقرار
Sub PersistTag ( _
    startIndex As Integer, _
    length As Integer, _
    propertyBag As ISmartTagProperties _
)
void PersistTag(
    int startIndex,
    int length,
    ISmartTagProperties propertyBag
)

المعلمات

  • startIndex
    النوع: System.Int32
    الموضع في الفقرة الموقع علامة ذكية يبدأ.
  • length
    النوع: System.Int32
    الالطول علامة ذكية.
  • propertyBag
    النوع: Microsoft.Office.Interop.SmartTag.ISmartTagProperties
    حقيبة خاصية الذي يحتوي على مفتاح و أزواج للرمز المميز للقيمة.Can benullمرجع خالٍ (لا شيء في Visual Basic).

استثناءات

استثناء: شرط
InvalidOperationException

PersistTagتم استدعاء ليس منRecognizeأسلوب.

ملاحظات

باستدعاء PersistTagمن تطبيق Recognizeالأسلوب للإشارة إلى أن علامة ذكية تم العثور عليها في نص. استخدام propertyBagلتنفيذ أي خصائص مخصصة ذكى علامة. يمكنك استخدام هذه الخصائص لتخصيص عملية أخذ عند أحد العناصر من قائمة المختصرة للعلامة ذكى هو المحدد.

أمثلة

يلي تعليمات برمجية مثال يوضح كيفية استدعاء PersistTagمن تطبيق Recognizeالأسلوب. يقارن هذا التطبيق لكل علامة ذكية المصطلح إلى محتويات الفقرة. لكل حد العلامات ذكى في الفقرة، يضيف خاصية علامات ذكية مخصصة التعليمة البرمجية ومن ثم يستخدم PersistTagالطريقة للتعرف على العلامات ذكى. يفترض هذا المثال أن قيامك بإضافة مرجع إلى من Microsoft.المكتب.Interop.SmartTag من علامة تبويب .NET من صندوق الحوار تمت الإضافة مرجع. Th هو المثال رمز هو جزءا من بقعة صغيرة مثال عن توفيرها ل ISmartTagExtensionالواجهة.

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);
        }
    }
}

أمن NET Framework.

راجع أيضًَا

المرجع

SmartTagRecognizeContext واجهة

SmartTagRecognizeContext الأعضاء

Microsoft.Office.Tools.Word مساحة الاسم