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
openerILibraryDatasetOpenerThe 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
itemsIReadOnlyList<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
itemsIReadOnlyList<CollectionItem>The items to open (downloaded online items localised first).
deferboolTrue to load as the items come into view (where the host supports it).
sourceOfFunc<CollectionItem, LibrarySourceLabel>The Library source of an item; null for none.
cancellationTokenCancellationTokenCancels the load.
Returns
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
itemsIReadOnlyList<CollectionItem>The items to open (downloaded online items localised first).
deferboolTrue to load as the items come into view (where the host supports it).
cancellationTokenCancellationTokenCancels the load.
Returns
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
itemsIEnumerable<CollectionItem>The items to open (downloaded online items localised first).
sourceOfFunc<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
itemCollectionItemThe library item (its downloaded copy for a downloaded online item).
Returns
Events
Changed
Raised after a load, and when any opened item's state changes.
public event EventHandler? Changed