Skip to content

Lookup

Namespace Nfty.Ticket in assembly Nfty.Ticket.

public static class Lookup

Lookup helpers shared by every assembly that resolves ids to things.

Methods

ById<T>(IEnumerable<T?>, Func<T?, string>)

public static Dictionary<string, T?> ById<T>(IEnumerable<T?> items, Func<T?, string> id);

Indexes items by id, ordinally, tolerating duplicates.

Parameters

  • items (IEnumerable<T?>) - The items.
  • id (Func<T?, string>) - Reads an item's id.

Type parameters

  • T - The item type.

Returns. The items by id.

Remarks

Last one wins and nothing throws: a transiently invalid book (a duplicate id) is a normal state for the callers that must keep working mid-edit, and deciding that a duplicate is a mistake is the validator's job, not this lookup's. ToDictionary throws a bare ArgumentException on a duplicate; this is the one place that choice is made.