Пример #1
0
        public override void PropagateAssert(IExecutionContext context, IList <Fact> facts)
        {
            var joinedSets  = JoinedSets(context, facts);
            var aggregation = new Aggregation();

            foreach (var set in joinedSets)
            {
                if (set.Facts.Count == 0)
                {
                    continue;
                }
                var matchingFacts = new List <Fact>();
                foreach (var fact in set.Facts)
                {
                    if (MatchesConditions(context, set.Tuple, fact))
                    {
                        matchingFacts.Add(fact);
                    }
                }
                if (matchingFacts.Count > 0)
                {
                    IAggregator aggregator = GetAggregator(set.Tuple);
                    var         results    = aggregator.Add(set.Tuple, matchingFacts);
                    aggregation.Add(set.Tuple, results);
                }
            }
            PropagateAggregation(context, aggregation);
        }
Пример #2
0
        public override void PropagateAssert(IExecutionContext context, IList <Tuple> tuples)
        {
            var joinedSets  = JoinedSets(context, tuples);
            var aggregation = new Aggregation();

            foreach (var set in joinedSets)
            {
                var factObjects = new List <object>();
                foreach (var fact in set.Facts)
                {
                    if (MatchesConditions(context, set.Tuple, fact))
                    {
                        factObjects.Add(fact.Object);
                    }
                }
                IAggregator aggregator = CreateAggregator(set.Tuple);
                var         results    = aggregator.Add(factObjects);
                aggregation.Add(set.Tuple, results);
            }
            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;
                }
            }
        }