コード例 #1
0
        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);
        }
コード例 #2
0
        private 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
            ArrayDeque<FilterHandleCallback> matches = new ArrayDeque<FilterHandleCallback>();

            int currentConsumption = int.MinValue;
            foreach (FilterHandleCallback callback in allStmtMatches) {
                if (!(callback is EvalFilterStateNodeConsume)) {
                    continue;
                }

                EvalFilterStateNodeConsume node = (EvalFilterStateNodeConsume) callback;
                int? consumption = node.EvalFilterNode.FactoryNode.ConsumptionLevel;
                if (consumption == null) {
                    consumption = 0;
                }

                if (consumption > currentConsumption) {
                    matches.Clear();
                    currentConsumption = consumption.Value;
                }

                if (consumption == currentConsumption) {
                    matches.Add(callback);
                }
            }

            // execute matches
            foreach (FilterHandleCallback match in matches) {
                match.MatchFound(theEvent, null);
            }
        }