public override void MatchFound(EventBean theEvent, ICollection <FilterHandleCallback> allStmtMatches) { // not receiving the remaining matches simply means we evaluate the event if (allStmtMatches == null) { base.MatchFound(theEvent, null); return; } EvalFilterConsumptionHandler handler = EvalFilterNode.Context.ConsumptionHandler; ProcessMatches(handler, theEvent, allStmtMatches); }
public static void ProcessMatches(EvalFilterConsumptionHandler handler, EventBean theEvent, ICollection <FilterHandleCallback> allStmtMatches) { // ignore all other callbacks for the same event if (handler.LastEvent == theEvent) { return; } handler.LastEvent = theEvent; // evaluate consumption for all same-pattern filters var matches = new LinkedList <FilterHandleCallback>(); var currentConsumption = int.MinValue; foreach (FilterHandleCallback callback in allStmtMatches) { if (!(callback is EvalFilterStateNodeConsume)) { continue; } var node = (EvalFilterStateNodeConsume)callback; var consumption = node.EvalFilterNode.FactoryNode.ConsumptionLevel; if (consumption == null) { consumption = 0; } if (consumption > currentConsumption) { matches.Clear(); currentConsumption = consumption.Value; } if (consumption == currentConsumption) { matches.AddLast(callback); } } // execute matches foreach (FilterHandleCallback match in matches) { match.MatchFound(theEvent, null); } }