Method MatchDisplayNamesAsync
- Namespace
- MailFathom.Application.Contacts
- Assembly
- MailFathom.Application.dll
MatchDisplayNamesAsync(ContactBookScope, IReadOnlyCollection<ContactDisplayName>, CancellationToken)
Reads who each name resolves to, by the whole of that name rather than by part of it.
Task<IReadOnlyDictionary<ContactDisplayName, ContactMatch>> MatchDisplayNamesAsync(ContactBookScope scope, IReadOnlyCollection<ContactDisplayName> displayNames, CancellationToken cancellationToken)
Parameters
scopeContactBookScopeThe books read.
displayNamesIReadOnlyCollection<ContactDisplayName>The names to resolve, at most one page of the book's worth.
cancellationTokenCancellationTokenCancels the read.
Returns
- Task<IReadOnlyDictionary<ContactDisplayName, ContactMatch>>
An entry for every supplied name, keyed by the name as supplied, carrying the one contact under it or how many carry it; a name nobody carries reports none.
Remarks
The comparison is on each name's whole comparison form, which is what separates this from the contained match a page's search performs: a lookup that addresses a message resolves to one person or to nobody, and text that merely appears inside somebody's name is not that person being named. Both are answered from the listing index the book is ordered by.
The count is exact and counts only the records the scope shows, so a collected record hidden by one the user wrote down does not make their own name ambiguous. The addresses of the people an ambiguous name counted are never read, so a name a hundred collected contacts happen to share costs one number rather than a page of somebody else's correspondents. A name resolving to one person answers with that person and with the count that decided it read together, so no caller can be handed a contact the scope no longer shows uniquely.
Every supplied name is answered rather than only the ones somebody carries, because ContactMatch already states "nobody" and a caller reading a set has to tell that answer from a name the read never covered.
Exceptions
- ArgumentNullException
Thrown when a required argument is null.
- ArgumentOutOfRangeException
Thrown when more names are supplied than one page of the book holds.