Table of Contents

Interface IAggregator

Namespace
NRules.Aggregators
Assembly
NRules.dll

Base interface for fact aggregators. An aggregator is a stateful element of the rules engine, that receives matching facts of a particular kind, and can combine them into a synthetic fact, that is then used by the downstream logic in the rule. Aggregator also receives updates and removals for the matching facts, so that it can keep the corresponding aggregate facts in sync. An aggregator must be supplemented by a corresponding implementation of IAggregatorFactory that knows how to create new instances of the aggregator.

public interface IAggregator

Methods

Add(AggregationContext, ITuple, IEnumerable<IFact>)

Called by the rules engine when new facts enter corresponding aggregator.

IEnumerable<AggregationResult> Add(AggregationContext context, ITuple tuple, IEnumerable<IFact> facts)

Parameters

context AggregationContext

Aggregation context.

tuple ITuple

Tuple containing preceding partial matches.

facts IEnumerable<IFact>

New facts to add to the aggregate.

Returns

IEnumerable<AggregationResult>

Results of the operation on the aggregate, based on the added facts.

Modify(AggregationContext, ITuple, IEnumerable<IFact>)

Called by the rules engine when existing facts are modified in the corresponding aggregator.

IEnumerable<AggregationResult> Modify(AggregationContext context, ITuple tuple, IEnumerable<IFact> facts)

Parameters

context AggregationContext

Aggregation context.

tuple ITuple

Tuple containing preceding partial matches.

facts IEnumerable<IFact>

Existing facts to update in the aggregate.

Returns

IEnumerable<AggregationResult>

Results of the operation on the aggregate, based on the modified facts.

Remove(AggregationContext, ITuple, IEnumerable<IFact>)

Called by the rules engine when existing facts are removed from the corresponding aggregator.

IEnumerable<AggregationResult> Remove(AggregationContext context, ITuple tuple, IEnumerable<IFact> facts)

Parameters

context AggregationContext

Aggregation context.

tuple ITuple

Tuple containing preceding partial matches.

facts IEnumerable<IFact>

Existing facts to remove from the aggregate.

Returns

IEnumerable<AggregationResult>

Results of the operation on the aggregate, based on the removed facts.