共用方式為


XmlStreamStore.GetAnnotations 方法

定義

傳回存放區中的所有註解清單。

多載

GetAnnotations()

傳回存放區中的所有註解清單。

GetAnnotations(ContentLocator)

傳回註解清單,這些註解擁有的 Anchors 具有從相符 ContentLocatorPart 順序起始的定位器。

範例

下列範例示範如何使用 GetAnnotations 方法來判斷存放區中是否包含任何批註。

// ---------------------------- 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()

傳回存放區中的所有註解清單。

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)

傳回

IList<Annotation>

目前存放區中所有附註的清單。

例外狀況

已在存放區中呼叫 Dispose

範例

下列範例示範如何使用 GetAnnotations 方法來判斷存放區中是否有任何注釋。

// ---------------------------- 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 永遠不會傳回 null ;不過,如果存放區不包含批註,清單可能會是空的。

另請參閱

適用於

GetAnnotations(ContentLocator)

傳回註解清單,這些註解擁有的 Anchors 具有從相符 ContentLocatorPart 順序起始的定位器。

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)

參數

anchorLocator
ContentLocator

要傳回其相符註解的起始 ContentLocatorPart 順序。

傳回

IList<Annotation>

註解清單,這些註解擁有的 Anchors 具有啟動和符合指定之 anchorLocator 的定位器;如果找不到符合的註解,則為 null

範例

下列範例示範如何使用 GetAnnotations 方法來判斷存放區中是否有任何注釋。

// ---------------------------- 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 方法會在內部使用 StartsWith 類別的 ContentLocator 方法來搜尋並比對要傳回的注釋。

另請參閱

適用於