swiftlys2/docs/api/releases/features/ai/
API Reference › Menu.Components

CollectionSelectionComponent`1

Class
Namespace: SwiftlyS2.Shared.Menu.Components · Assembly: SwiftlyS2.CS2.dll
public sealed class CollectionSelectionComponent<TItem> : SelectionComponentBase<TItem>, IMenuComponent, IMenuRowSource
Inherits object, MenuComponentBase, SelectionComponentBase<TItem>
View source

Constructors

CollectionSelectionComponent(Func<Task<IReadOnlyList<TItem>>>, string?, IEqualityComparer<TItem>?)

Creates a selection list.

public CollectionSelectionComponent(Func<Task<IReadOnlyList<TItem>>> loader, string? id = null, IEqualityComparer<TItem>? comparer = null)
Parameters
  • loaderFunc<Task<IReadOnlyList<TItem>>>Produces the items. Runs on the collection loader thread.
  • idstring?optionalA stable id, or null to generate one.
  • comparerIEqualityComparer<TItem>?optionalHow items are compared, or null for the default. Items are kept across reloads by this comparison.

Properties

List

The list underneath. Use it for the loading, empty and failed texts. Its RowRenderer , OnItemSelected and formatters are owned by this component.

public PagedCollectionComponent<TItem> List { get; }
Property Value
PagedCollectionComponent<TItem>

Methods

GetInnerRows(IMenuSession, MenuRowContext)

The rows of the list underneath.

protected override IReadOnlyList<IMenuComponent> GetInnerRows(IMenuSession session, MenuRowContext context)
Parameters

Reload()

Runs the loader again. Selected items that are still loaded stay selected.

public void Reload()

TryGetCandidates(IMenuSession, MenuRowContext, out IEnumerable<TItem>)

Every item DefaultSelected should be asked about. Return false while they are not known yet.

protected override bool TryGetCandidates(IMenuSession session, MenuRowContext context, out IEnumerable<TItem> candidates)
Parameters
Returns