แก้ไข

แชร์ผ่าน


XmlStreamStore.GetAnnotations Method

Definition

Returns a list of all the annotations in the store.

Overloads

GetAnnotations()

Returns a list of all the annotations in the store.

GetAnnotations(ContentLocator)

Returns a list of annotations that have Anchors with locators that begin with a matching ContentLocatorPart sequence.

Examples

The following example shows how to use the GetAnnotations method to determine whether there are any annotations contained in the store.

// ---------------------------- CloseFile -----------------------------
private void CloseFile()
{
    // If there are existing annotations, then they should be saved.
    if (_annStore.GetAnnotations().Count > 0)
    {
        string backupFile = _fileName + ".annotations" + ".xml";
        FileStream backupStream = new FileStream(backupFile, FileMode.Create);
        CopyStream(_annotationBuffer, backupStream);
        _annStore.Flush();
        _annServ.Disable();
    }
}

GetAnnotations()

Returns a list of all the annotations in the store.

public:
 override System::Collections::Generic::IList<System::Windows::Annotations::Annotation ^> ^ GetAnnotations();
public override System.Collections.Generic.IList<System.Windows.Annotations.Annotation> GetAnnotations ();
override this.GetAnnotations : unit -> System.Collections.Generic.IList<System.Windows.Annotations.Annotation>
Public Overrides Function GetAnnotations () As IList(Of Annotation)

Returns

The list of all annotations that are currently in the store.

Exceptions

Dispose has been called on the store.

Examples

The following example shows how to use the GetAnnotations method to determine whether there are any annotations in the store.

// ---------------------------- CloseFile -----------------------------
private void CloseFile()
{
    // If there are existing annotations, then they should be saved.
    if (_annStore.GetAnnotations().Count > 0)
    {
        string backupFile = _fileName + ".annotations" + ".xml";
        FileStream backupStream = new FileStream(backupFile, FileMode.Create);
        CopyStream(_annotationBuffer, backupStream);
        _annStore.Flush();
        _annServ.Disable();
    }
}

Remarks

The GetAnnotations method will never return null; however the list may be empty if the store contains no annotations.

See also

Applies to

GetAnnotations(ContentLocator)

Returns a list of annotations that have Anchors with locators that begin with a matching ContentLocatorPart sequence.

public:
 override System::Collections::Generic::IList<System::Windows::Annotations::Annotation ^> ^ GetAnnotations(System::Windows::Annotations::ContentLocator ^ anchorLocator);
public override System.Collections.Generic.IList<System.Windows.Annotations.Annotation> GetAnnotations (System.Windows.Annotations.ContentLocator anchorLocator);
override this.GetAnnotations : System.Windows.Annotations.ContentLocator -> System.Collections.Generic.IList<System.Windows.Annotations.Annotation>
Public Overrides Function GetAnnotations (anchorLocator As ContentLocator) As IList(Of Annotation)

Parameters

anchorLocator
ContentLocator

The starting ContentLocatorPart sequence to return matching annotations for.

Returns

The list of annotations that have Anchors with locators that start and match the given anchorLocator; otherwise, null if no matching annotations were found.

Examples

The following example shows how to use the GetAnnotations method to determine whether there are any annotations in the store.

// ---------------------------- CloseFile -----------------------------
private void CloseFile()
{
    // If there are existing annotations, then they should be saved.
    if (_annStore.GetAnnotations().Count > 0)
    {
        string backupFile = _fileName + ".annotations" + ".xml";
        FileStream backupStream = new FileStream(backupFile, FileMode.Create);
        CopyStream(_annotationBuffer, backupStream);
        _annStore.Flush();
        _annServ.Disable();
    }
}

Remarks

This GetAnnotations method internally uses the StartsWith method of the ContentLocator class to search and match for the annotations to return.

See also

Applies to