Table of Contents

Method Create

Namespace
MailFathom.Domain.Contacts
Assembly
MailFathom.Domain.dll

Create(ContactId, ContactDisplayName, IReadOnlyCollection<EmailAddress>, EmailAddress, ContactNote?, ContactOrigin, DateTimeOffset, DateTimeOffset)

Builds a contact from what an owner or collection supplied, enforcing every invariant the book rests on.

public static Contact Create(ContactId id, ContactDisplayName displayName, IReadOnlyCollection<EmailAddress> addresses, EmailAddress preferredAddress, ContactNote? note, ContactOrigin origin, DateTimeOffset recordedAt, DateTimeOffset amendedAt)

Parameters

id ContactId

The identity this contact keeps for as long as it is held.

displayName ContactDisplayName

The name to record.

addresses IReadOnlyCollection<EmailAddress>

Every address this person uses; two spellings of one address count once.

preferredAddress EmailAddress

The address to use by default, which must be one of addresses.

note ContactNote?

What the owner wrote about this person, or null.

origin ContactOrigin

How this contact came to be in the book.

recordedAt DateTimeOffset

When this contact entered the book.

amendedAt DateTimeOffset

When it was last amended, which is recordedAt for a new contact.

Returns

Contact

A contact whose addresses are deduplicated and ordered, with the preferred one first.

Remarks

Two spellings of one address inside one record are one address, so they are merged rather than refused: they name the same mailbox of the same person, and refusing would ask an owner to resolve a difference their mail server does not make. Two spellings across two contacts are a different question, which the store answers by refusing the second holder.

Exceptions

ArgumentNullException

Thrown when addresses is null.

ArgumentException

Thrown when no address is supplied, when more than MaximumAddressCount remain after two spellings of one address are merged, or when preferredAddress is not among them.

ArgumentOutOfRangeException

Thrown when origin names no declared value.