Method TryCreate
- Namespace
- MailFathom.Domain.Folders
- Assembly
- MailFathom.Domain.dll
TryCreate(string?, out MailFolderReference)
Reads the text a caller named a folder with, without raising on text that names none.
public static bool TryCreate(string? value, out MailFolderReference reference)
Parameters
valuestringThe alias, or a role written as
role:<name>.referenceMailFolderReferenceThe reference when the text names one; otherwise the unspecified default.
Returns
Remarks
The role name is matched against the declared names rather than parsed, which refuses two spellings that
TryParse<TEnum>(string, bool, out TEnum) accepts and neither of which any operator meant.
role:4 would bind a typo onto whichever member currently carries that number. role:Archive,Drafts
is worse: a comma-separated list is combined by bitwise OR whether or not the enumeration carries
FlagsAttribute, and these values are dense, so Archive|Drafts is Sent — a real role
nobody wrote, which IsDefined<TEnum>(TEnum) then confirms. Both arrive here from a tool
argument as readily as from configuration.