public void Check(EMail mail) { // Bootstrapping var ruleChecker = new RuleChecker( new List<ISpamRule> { new MyFirstRule(), new MySecondRule(), // … }); ruleChecker.CheckMail(mail); // ... }
public SpamResult CheckMail(EMail mail) { foreach (var rule in _rules) { var result = rule.CheckMail(mail); if (result != SpamResult.Unknown) return result; } return SpamResult.Unknown; }
private static SpamResult TestRule2(EMail mail) { // I don’t care about the concrete rules return SpamResult.Ok; }
public SpamResult CheckMail(EMail mail) { // I don’t care about this return SpamResult.Ok; }
public SpamResult CheckMail(EMail mail) { var result = TestRule1(mail); if (result != SpamResult.Unknown) return result; result = TestRule2(mail); if (result != SpamResult.Unknown) return result; // … return SpamResult.Unknown; }