コード例 #1
0
ファイル: AggregateNode.cs プロジェクト: toenners/NRules
        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 void HandleReceived(ResponseMessage <JToken> received)
        {
            var receivedData = typeof(T) == typeof(JToken)
                ? new[] { received.Result.Data }
                : _graphSONReader.ToObject(received.Result.Data);

            foreach (var d in receivedData)
            {
                if (received.Result.Meta.ContainsKey(Tokens.ArgsSideEffectKey))
                {
                    if (_aggregator == null)
                    {
                        _aggregator =
                            new AggregatorFactory().GetAggregatorFor(
                                (string)received.Result.Meta[Tokens.ArgsAggregateTo]);
                    }
                    _aggregator.Add(d);
                    _isAggregatingSideEffects = true;
                }
                else
                {
                    _result.Add(d);
                }
            }
        }
コード例 #3
0
ファイル: AggregateNode.cs プロジェクト: sscctech/NRules
        public override void PropagateAssert(IExecutionContext context, Fact fact)
        {
            var tuples = MatchingTuples(context, fact);

            foreach (var tuple in tuples)
            {
                IAggregator aggregator = Aggregator(context, tuple);
                var         results    = aggregator.Add(fact.Object);
                HandleAggregationResult(context, results, tuple);
            }
        }
コード例 #4
0
ファイル: AggregateNode.cs プロジェクト: sscctech/NRules
        public override void PropagateAssert(IExecutionContext context, Tuple tuple)
        {
            IAggregator aggregator    = Aggregator(context, tuple);
            var         matchingFacts = MatchingFacts(context, tuple);

            foreach (var matchingFact in matchingFacts)
            {
                var results = aggregator.Add(matchingFact.Object);
                HandleAggregationResult(context, results, tuple);
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        public void Add(Aggregation aggregation, Tuple tuple, IEnumerable <Fact> facts)
        {
            var results = _aggregator.Add(tuple, facts);

            AddAggregationResult(aggregation, tuple, results);
        }