Class MailRuleFacts
- Namespace
- MailFathom.Application.Rules.Facts
- Assembly
- MailFathom.Application.dll
Resolves the declared facts for one email, computing each at most once and only when a condition names it.
public sealed class MailRuleFacts
- Inheritance
-
MailRuleFacts
- Inherited Members
Remarks
This is where the cost bound the fact surface promises is actually kept. A condition reaches a fact by name, so a fact no condition names is never asked for; a fact several conditions name is asked for once, because the answer is remembered for the whole rule set rather than for one rule. Only BodyText costs anything to resolve, and it is the fact those two properties exist for. FolderRole costs a look at configuration instead of a read of stored content, which is cheap but is still not paid by a rule set that never asks what a folder is for.
The evaluation instant is taken once, when this is constructed, rather than read per rule. Otherwise AgeInDays could answer differently to two rules of the same pass, and a rule set would stop being one reading of one email.
One instance serves one evaluation of one rule set and is not safe to use from several at once. Nothing here locks, because an evaluation walks its rules in declared order and a condition's own operands are evaluated one at a time.
Constructors
- MailRuleFacts(MailRuleEmailFacts, IMailRuleBodyTextReader, IMailFolderMappingReader, DateTimeOffset)
Initializes the fact surface for one email at one instant.
Properties
- Account
Gets the configured identifier of the account this email belongs to.
- ResolvedFacts
Gets the facts that have actually been resolved, which is what proves an unnamed fact cost nothing.
Methods
- ResolveAsync(MailRuleFact, CancellationToken)
Resolves one fact's value in the form a condition compares against.
- TakeFactsRead()
Takes the facts read since this was last called, and begins recording afresh.