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
idContactIdThe identity this contact keeps for as long as it is held.
displayNameContactDisplayNameThe name to record.
addressesIReadOnlyCollection<EmailAddress>Every address this person uses; two spellings of one address count once.
preferredAddressEmailAddressThe address to use by default, which must be one of
addresses.noteContactNote?What the owner wrote about this person, or null.
originContactOriginHow this contact came to be in the book.
recordedAtDateTimeOffsetWhen this contact entered the book.
amendedAtDateTimeOffsetWhen it was last amended, which is
recordedAtfor 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
addressesis null.- ArgumentException
Thrown when no address is supplied, when more than MaximumAddressCount remain after two spellings of one address are merged, or when
preferredAddressis not among them.- ArgumentOutOfRangeException
Thrown when
originnames no declared value.