Class NCalcMailRuleConditionCompiler
- Namespace
- MailFathom.Infrastructure.Rules
- Assembly
- MailFathom.Infrastructure.dll
Reads one authored condition, refusing everything the expression language would have let through.
public sealed class NCalcMailRuleConditionCompiler : IMailRuleConditionCompiler
- Inheritance
-
NCalcMailRuleConditionCompiler
- Implements
- Inherited Members
Remarks
Four things are checked here and each of them is checked because nothing else would. Length, before the text reaches a parser at all. Syntax, which is the one thing the language reports itself. Then the walk that gives every part of the tree a type, which is where an unknown fact, a function that does not exist, an operator this surface does not admit, and a comparison that could never hold are all refused. Finally the root's own type, because a condition that answers with text or a number is not a condition, and treating a non-boolean as truthy would make a rule's meaning depend on a coercion nobody wrote down.
Everything is reported together rather than at the first defect, because an operator fixing a rule set should not have to restart a deployment to discover the next mistake in it.
Public rather than internal, unlike most of this project, because the composition root constructs one directly. A rule set is proven usable while the host is being composed, which is before the container exists and therefore before anything could be resolved from it. The type holds no state, so one instance serves composition, every reload, and every pass.
Methods
- Compile(string, string?, MailRuleConditionBounds)
Reads one rule's condition under the bounds the rule set was declared with.