public async Task <RuleSetOutcome> EvaluateAsync(TSubject subject, RuleSetOptions options = null) { if (_rules.Count == 0) { throw new InvalidOperationException($"RuleSet '{RuleSetId}' has no rules defined"); } options = options ?? _defaultOptions; var outcome = new RuleSetOutcome(); foreach (var rule in _rules) { var ruleOutcome = await rule.EvaluateAsync(subject); outcome.RuleOutcomes.Add(ruleOutcome); } outcome.Decision = outcome.RuleOutcomes.CalculateOutcome(options); return(outcome); }
protected RuleSet(string ruleSetId) { RuleSetId = ruleSetId; _defaultOptions = RuleSetOptions.ZeroTolerance; _rules = new List <IRule <TSubject> >(); }