コード例 #1
0
ファイル: AggregateNode.cs プロジェクト: zhrjin/NRules
        public override void PropagateRetract(IExecutionContext context, IList <Tuple> tuples)
        {
            var aggregation = new Aggregation();

            foreach (var tuple in tuples)
            {
                IFactAggregator aggregator = RemoveFactAggregator(tuple);
                if (aggregator != null)
                {
                    aggregation.Remove(tuple, aggregator.AggregateFacts);
                }
            }
            PropagateAggregation(context, aggregation);
        }
コード例 #2
0
        public override void PropagateRetract(IExecutionContext context, List <Tuple> tuples)
        {
            var aggregation = new Aggregation();

            using (var counter = PerfCounter.Retract(context, this))
            {
                foreach (var tuple in tuples)
                {
                    IFactAggregator aggregator = RemoveFactAggregator(context, tuple);
                    if (aggregator != null)
                    {
                        aggregation.Remove(tuple, aggregator.AggregateFacts);
                    }
                }

                counter.AddInputs(tuples.Count);
                counter.AddOutputs(aggregation.Count);
            }

            PropagateAggregation(context, aggregation);
        }
コード例 #3
0
        private void AddAggregationResult(Aggregation aggregation, Tuple tuple, IEnumerable <AggregationResult> results)
        {
            foreach (var result in results)
            {
                switch (result.Action)
                {
                case AggregationAction.Added:
                    var addedFact = CreateAggregateFact(result.Aggregate);
                    aggregation.Add(tuple, addedFact);
                    break;

                case AggregationAction.Modified:
                    var modifiedFact = GetAggregateFact(result.Aggregate, result.Previous);
                    aggregation.Modify(tuple, modifiedFact);
                    break;

                case AggregationAction.Removed:
                    var removedFact = RemoveAggregateFact(result.Aggregate);
                    aggregation.Remove(tuple, removedFact);
                    break;
                }
            }
        }
コード例 #4
0
ファイル: AggregateNode.cs プロジェクト: zhrjin/NRules
 private void ResetAggregator(Aggregation aggregation, Tuple tuple, IFactAggregator aggregator)
 {
     tuple.RemoveState <IFactAggregator>(this);
     aggregation.Remove(tuple, aggregator.AggregateFacts);
 }
コード例 #5
0
 private void ResetAggregator(IExecutionContext context, Aggregation aggregation, Tuple tuple, IFactAggregator aggregator)
 {
     context.WorkingMemory.RemoveState <IFactAggregator>(this, tuple);
     aggregation.Remove(tuple, aggregator.AggregateFacts);
 }