public IEnumerable <Query> All() { yield return(this); if (And != null) { foreach (var q in And.All()) { yield return(q); } } if (Or != null) { foreach (var q in Or.All()) { yield return(q); } } if (Not != null) { foreach (var q in Not.All()) { yield return(q); } } }
public bool Evaluate(string rawMessage) { if (rawMessage == null) { return(false); } bool AndResult = true, OrResult = true, NotAllResult = true, NotAnyResult = true; if (And != null && And.Count > 0) { AndResult = And.All(x => Regex.IsMatch(rawMessage, x, (RegexOptions)Options)); } if (Or != null && Or.Count > 0) { OrResult = Or.Any(x => Regex.IsMatch(rawMessage, x, (RegexOptions)Options)); } if (NotAll != null && NotAll.Count > 0) { NotAllResult = !NotAll.All(x => Regex.IsMatch(rawMessage, x, (RegexOptions)Options)); } if (NotAny != null && NotAny.Count > 0) { NotAnyResult = !NotAny.Any(x => Regex.IsMatch(rawMessage, x, (RegexOptions)Options)); } return(AndResult && OrResult && NotAllResult && NotAnyResult); }
public bool Evaluate(MessageDataItem dataItem) { if (And != null) { return(And.All(x => x?.Evaluate(dataItem) == true)); } if (Or != null) { return(Or.Any(x => x?.Evaluate(dataItem) == true)); } if (Not != null) { return(!Not.Evaluate(dataItem)); } if (Exists != null) { if (Exists.Attribute != null) { if (dataItem.AttributeExists(Exists.Attribute.Name ?? "")) { if (dataItem.GetAttributeAsVariant(Exists.Attribute.Name).Type == Exists.Attribute.Type) { return(true); } } } } if (SimpleExpression != null) { return(SimpleExpression.Evaluate(dataItem)); } if (InExpression != null) { return(InExpression.Evaluate(dataItem)); } if (RegExExpression != null) { return(RegExExpression.Evaluate(dataItem)); } if (ModuleExpressionModule != null) { return(ModuleExpressionModule.IsMatch(dataItem)); } return(false); }