Table of Contents

Class LibraryLoader

Namespace
EncDotNet.S100.Collections.Library
Assembly
EncDotNet.S100.Collections.dll

Opens library items in a host's session (issues #655, #792): skips what cannot be opened (online, missing, catalogue-only, unknown product), groups the rest by exchange set (Plan(IEnumerable<CollectionItem>, Func<CollectionItem, LibrarySourceLabel?>?)) and opens each group through the host's ILibraryDatasetOpener. UI-free, so the viewer and a headless host share it.

public sealed class LibraryLoader : IDisposable
Inheritance
LibraryLoader
Implements
Inherited Members

Constructors

LibraryLoader(ILibraryDatasetOpener)

Creates a loader that opens through opener.

public LibraryLoader(ILibraryDatasetOpener opener)

Parameters

opener ILibraryDatasetOpener

The host's opener.

Methods

Close(IReadOnlyList<CollectionItem>)

Closes the open (or deferred) datasets of the local items among items; others are ignored.

public int Close(IReadOnlyList<CollectionItem> items)

Parameters

items IReadOnlyList<CollectionItem>

The items (downloaded online items localised first).

Returns

int

How many datasets were closed.

Dispose()

Stops listening to the opener.

public void Dispose()

LoadAsync(IReadOnlyList<CollectionItem>, bool, Func<CollectionItem, LibrarySourceLabel?>?, CancellationToken)

Opens the local items among items as LoadAsync(IReadOnlyList<CollectionItem>, bool, CancellationToken) does, labelling each group with its Library source.

public Task<LibraryLoadResult> LoadAsync(IReadOnlyList<CollectionItem> items, bool defer, Func<CollectionItem, LibrarySourceLabel?>? sourceOf, CancellationToken cancellationToken = default)

Parameters

items IReadOnlyList<CollectionItem>

The items to open (downloaded online items localised first).

defer bool

True to load as the items come into view (where the host supports it).

sourceOf Func<CollectionItem, LibrarySourceLabel>

The Library source of an item; null for none.

cancellationToken CancellationToken

Cancels the load.

Returns

Task<LibraryLoadResult>

LoadAsync(IReadOnlyList<CollectionItem>, bool, CancellationToken)

Opens the local items among items: loads them now, or with defer registers them to load as they come into view. Never throws for an unreadable group or item: the result counts it as skipped and says why.

public Task<LibraryLoadResult> LoadAsync(IReadOnlyList<CollectionItem> items, bool defer, CancellationToken cancellationToken = default)

Parameters

items IReadOnlyList<CollectionItem>

The items to open (downloaded online items localised first).

defer bool

True to load as the items come into view (where the host supports it).

cancellationToken CancellationToken

Cancels the load.

Returns

Task<LibraryLoadResult>

Plan(IEnumerable<CollectionItem>, Func<CollectionItem, LibrarySourceLabel?>?)

Splits items into the groups that can be opened and a count of those that cannot (not local, unknown product, or missing).

public static (IReadOnlyList<LibraryOpenGroup> Groups, int Skipped) Plan(IEnumerable<CollectionItem> items, Func<CollectionItem, LibrarySourceLabel?>? sourceOf = null)

Parameters

items IEnumerable<CollectionItem>

The items to open (downloaded online items localised first).

sourceOf Func<CollectionItem, LibrarySourceLabel>

The Library source of an item, labelling its group; null for none.

Returns

(IReadOnlyList<LibraryOpenGroup> Groups, int Skipped)

One group per exchange set or folder, in first-seen order, and the skipped count.

StateOf(CollectionItem)

The session state of item.

public LibraryLoadState StateOf(CollectionItem item)

Parameters

item CollectionItem

The library item (its downloaded copy for a downloaded online item).

Returns

LibraryLoadState

Events

Changed

Raised after a load, and when any opened item's state changes.

public event EventHandler? Changed

Event Type

EventHandler