Table of Contents

Class Element

Namespace
NRules.RuleModel.Builders
Assembly
NRules.RuleModel.dll

Factory class for rule elements.

public static class Element
Inheritance
Element
Inherited Members

Methods

Action(LambdaExpression)

Creates an action element that represents an action taken by the engine when the rule fires. The action element is created with the default trigger, which executes the action when rule is Activated or Reactivated.

public static ActionElement Action(LambdaExpression expression)

Parameters

expression LambdaExpression

Action expression. It must have IContext as it's first parameter.

Returns

ActionElement

Created element.

Action(LambdaExpression, ActionTrigger)

Creates an action element that represents an action taken by the engine when the rule fires.

public static ActionElement Action(LambdaExpression expression, ActionTrigger actionTrigger)

Parameters

expression LambdaExpression

Action expression. It must have IContext as it's first parameter.

actionTrigger ActionTrigger

Action trigger that indicates when the action should execute.

Returns

ActionElement

Created element.

ActionGroup(params ActionElement[])

Creates an action group element.

public static ActionGroupElement ActionGroup(params ActionElement[] actions)

Parameters

actions ActionElement[]

Action elements in the group.

Returns

ActionGroupElement

Created element.

See Also

ActionGroup(IEnumerable<ActionElement>)

Creates an action group element.

public static ActionGroupElement ActionGroup(IEnumerable<ActionElement> actions)

Parameters

actions IEnumerable<ActionElement>

Action elements in the group.

Returns

ActionGroupElement

Created element.

See Also

Aggregate(Type, string, IEnumerable<NamedExpressionElement>, PatternElement)

Creates an element that represents an aggregation of facts.

public static AggregateElement Aggregate(Type resultType, string name, IEnumerable<NamedExpressionElement> expressions, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

name string

Aggregate name.

expressions IEnumerable<NamedExpressionElement>

Expressions used to construct aggregates from individual facts.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Aggregate(Type, string, IEnumerable<NamedExpressionElement>, PatternElement, Type?)

Creates an element that represents an aggregation of facts.

public static AggregateElement Aggregate(Type resultType, string name, IEnumerable<NamedExpressionElement> expressions, PatternElement source, Type? customFactoryType)

Parameters

resultType Type

Type of the aggregate result.

name string

Aggregate name.

expressions IEnumerable<NamedExpressionElement>

Expressions used to construct aggregates from individual facts.

source PatternElement

Pattern that matches facts for aggregation.

customFactoryType Type

Factory type used construct aggregators for this aggregation.

Returns

AggregateElement

Created element.

Aggregate(Type, string, IEnumerable<KeyValuePair<string, LambdaExpression>>, PatternElement)

Creates an element that represents an aggregation of facts.

public static AggregateElement Aggregate(Type resultType, string name, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

name string

Aggregate name.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used to construct aggregates from individual facts.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Aggregate(Type, string, IEnumerable<KeyValuePair<string, LambdaExpression>>, PatternElement, Type?)

Creates an element that represents an aggregation of facts.

public static AggregateElement Aggregate(Type resultType, string name, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions, PatternElement source, Type? customFactoryType)

Parameters

resultType Type

Type of the aggregate result.

name string

Aggregate name.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used to construct aggregates from individual facts.

source PatternElement

Pattern that matches facts for aggregation.

customFactoryType Type

Factory type used construct aggregators for this aggregation.

Returns

AggregateElement

Created element.

AndGroup(params RuleElement[])

Creates a left-hand side group element that combines contained elements using an AND operator.

public static AndElement AndGroup(params RuleElement[] childElements)

Parameters

childElements RuleElement[]

Child elements contained in the group.

Returns

AndElement

Created element.

AndGroup(IEnumerable<RuleElement>)

Creates a left-hand side group element that combines contained elements using an AND operator.

public static AndElement AndGroup(IEnumerable<RuleElement> childElements)

Parameters

childElements IEnumerable<RuleElement>

Child elements contained in the group.

Returns

AndElement

Created element.

Binding(LambdaExpression)

Creates an element that represents results of an expression evaluation.

public static BindingElement Binding(LambdaExpression expression)

Parameters

expression LambdaExpression

Binding expression.

Returns

BindingElement

Created element.

Binding(Type?, LambdaExpression)

Creates an element that represents results of an expression evaluation.

public static BindingElement Binding(Type? resultType, LambdaExpression expression)

Parameters

resultType Type

Type of the expression result.

expression LambdaExpression

Binding expression.

Returns

BindingElement

Created element.

Collect(PatternElement)

Creates an element that aggregates matching facts into a collection.

public static AggregateElement Collect(PatternElement source)

Parameters

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Collect(Type?, PatternElement)

Creates an element that aggregates matching facts into a collection.

public static AggregateElement Collect(Type? resultType, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Condition(LambdaExpression)

Creates a condition element that represents a condition applied to elements matched by a pattern.

public static NamedExpressionElement Condition(LambdaExpression expression)

Parameters

expression LambdaExpression

Condition expression. It must have Boolean as its return type.

Returns

NamedExpressionElement

Created element.

Declaration(Type, string)

Creates a declaration with a given name and type to be used in other rule elements.

public static Declaration Declaration(Type type, string name)

Parameters

type Type

Declaration type.

name string

Declaration name.

Returns

Declaration

Created declaration.

Dependency(Declaration, Type)

Creates a dependency element.

public static DependencyElement Dependency(Declaration declaration, Type serviceType)

Parameters

declaration Declaration

Declaration that references the dependency.

serviceType Type

Type of the service that the dependency represents.

Returns

DependencyElement

Created element.

Dependency(Type, string)

Creates a dependency element.

public static DependencyElement Dependency(Type type, string name)

Parameters

type Type

Dependency type.

name string

Dependency name.

Returns

DependencyElement

Created element.

DependencyGroup(params DependencyElement[])

Creates a dependency group element.

public static DependencyGroupElement DependencyGroup(params DependencyElement[] dependencies)

Parameters

dependencies DependencyElement[]

Dependency elements in the group.

Returns

DependencyGroupElement

Created element.

See Also

DependencyGroup(IEnumerable<DependencyElement>)

Creates a dependency group element.

public static DependencyGroupElement DependencyGroup(IEnumerable<DependencyElement> dependencies)

Parameters

dependencies IEnumerable<DependencyElement>

Dependency elements in the group.

Returns

DependencyGroupElement

Created element.

See Also

Exists(RuleElement)

Creates an element that represents an existential quantifier.

public static ExistsElement Exists(RuleElement source)

Parameters

source RuleElement

Source element to apply the existential quantifier to.

Returns

ExistsElement

Created element.

Expression(string, LambdaExpression)

Creates a named expression element that can be used by other rule elements.

public static NamedExpressionElement Expression(string name, LambdaExpression expression)

Parameters

name string

Name of the expression.

expression LambdaExpression

The actual expression that this element represents.

Returns

NamedExpressionElement

Created element.

Filter(FilterType, LambdaExpression)

Creates an agenda filter element.

public static FilterElement Filter(FilterType filterType, LambdaExpression expression)

Parameters

filterType FilterType

Type of agenda filter.

expression LambdaExpression

Filter expression.

Returns

FilterElement

Created element.

FilterGroup(params FilterElement[])

Creates an agenda filter group element.

public static FilterGroupElement FilterGroup(params FilterElement[] filters)

Parameters

filters FilterElement[]

Agenda filter elements in the group.

Returns

FilterGroupElement

Created element.

See Also

FilterGroup(IEnumerable<FilterElement>)

Creates an agenda filter group element.

public static FilterGroupElement FilterGroup(IEnumerable<FilterElement> filters)

Parameters

filters IEnumerable<FilterElement>

Agenda filter elements in the group.

Returns

FilterGroupElement

Created element.

See Also

Flatten(Type, LambdaExpression, PatternElement)

Creates an element that flattens collections of elements from matching facts into a single set of facts.

public static AggregateElement Flatten(Type resultType, LambdaExpression selector, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

selector LambdaExpression

Expression that selects a collection of elements from a matching fact.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

ForAll(PatternElement, IEnumerable<PatternElement>)

Creates an element that represents a universal quantifier. Facts that match the basePattern must also match all other patterns.

public static ForAllElement ForAll(PatternElement basePattern, IEnumerable<PatternElement> patterns)

Parameters

basePattern PatternElement

Base patterns of the universal quantifier that defines the universe of facts to consider.

patterns IEnumerable<PatternElement>

Additional patterns of the universal quantifier that the fact matched by the base pattern must also satisfy.

Returns

ForAllElement

Created element.

Group(GroupType, IEnumerable<RuleElement>)

Creates a left-hand side group element, that contains pattern elements and nested group elements.

public static GroupElement Group(GroupType groupType, IEnumerable<RuleElement> childElements)

Parameters

groupType GroupType

Type of the group element.

childElements IEnumerable<RuleElement>

Child elements contained in the group.

Returns

GroupElement

Created element.

GroupBy(LambdaExpression, LambdaExpression, PatternElement)

Creates an element that aggregates matching facts into groups.

public static AggregateElement GroupBy(LambdaExpression keySelector, LambdaExpression elementSelector, PatternElement source)

Parameters

keySelector LambdaExpression

Expression that extracts grouping keys from source element.

elementSelector LambdaExpression

Expression that extracts elements to put into resulting groups.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

GroupBy(Type?, LambdaExpression, LambdaExpression, PatternElement)

Creates an element that aggregates matching facts into groups.

public static AggregateElement GroupBy(Type? resultType, LambdaExpression keySelector, LambdaExpression elementSelector, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

keySelector LambdaExpression

Expression that extracts grouping keys from source element.

elementSelector LambdaExpression

Expression that extracts elements to put into resulting groups.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Not(RuleElement)

Creates an element that represents a negative existential quantifier.

public static NotElement Not(RuleElement source)

Parameters

source RuleElement

Source element to apply the negative existential quantifier to.

Returns

NotElement

Created element.

OrGroup(params RuleElement[])

Creates a left-hand side group element that combines contained elements using an OR operator.

public static OrElement OrGroup(params RuleElement[] childElements)

Parameters

childElements RuleElement[]

Child elements contained in the group.

Returns

OrElement

Created element.

OrGroup(IEnumerable<RuleElement>)

Creates a left-hand side group element that combines contained elements using an OR operator.

public static OrElement OrGroup(IEnumerable<RuleElement> childElements)

Parameters

childElements IEnumerable<RuleElement>

Child elements contained in the group.

Returns

OrElement

Created element.

Pattern(Declaration, IEnumerable<NamedExpressionElement>, RuleElement?)

Creates a pattern element that represents a match over results of the source element.

public static PatternElement Pattern(Declaration declaration, IEnumerable<NamedExpressionElement> expressions, RuleElement? source)

Parameters

declaration Declaration

Declaration that references the pattern.

expressions IEnumerable<NamedExpressionElement>

Expressions used by the pattern to match elements.

source RuleElement

Source of the elements matched by the pattern. If it's null, the pattern matches facts in rules engine's working memory.

Returns

PatternElement

Created element.

Pattern(Declaration, IEnumerable<KeyValuePair<string, LambdaExpression>>)

Creates a pattern element that represents a match of facts in rules engine's working memory.

public static PatternElement Pattern(Declaration declaration, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions)

Parameters

declaration Declaration

Declaration that references the pattern.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used by the pattern to match elements.

Returns

PatternElement

Created element.

Pattern(Declaration, IEnumerable<KeyValuePair<string, LambdaExpression>>, RuleElement?)

Creates a pattern element that represents a match over results of the source element.

public static PatternElement Pattern(Declaration declaration, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions, RuleElement? source)

Parameters

declaration Declaration

Declaration that references the pattern.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used by the pattern to match elements.

source RuleElement

Source of the elements matched by the pattern. If it's null, the pattern matches facts in rules engine's working memory.

Returns

PatternElement

Created element.

Pattern(Type, string, IEnumerable<NamedExpressionElement>, RuleElement?)

Creates a pattern element that represents a match over results of the source element.

public static PatternElement Pattern(Type type, string name, IEnumerable<NamedExpressionElement> expressions, RuleElement? source)

Parameters

type Type

Type of elements matched by the pattern.

name string

Pattern name.

expressions IEnumerable<NamedExpressionElement>

Expressions used by the pattern to match elements.

source RuleElement

Source of the elements matched by the pattern. If it's null, the pattern matches facts in rules engine's working memory.

Returns

PatternElement

Created element.

Pattern(Type, string, IEnumerable<KeyValuePair<string, LambdaExpression>>)

Creates a pattern element that represents a match of facts in rules engine's working memory.

public static PatternElement Pattern(Type type, string name, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions)

Parameters

type Type

Type of facts matched by the pattern.

name string

Pattern name.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used by the pattern to match elements.

Returns

PatternElement

Created element.

Pattern(Type, string, IEnumerable<KeyValuePair<string, LambdaExpression>>, RuleElement?)

Creates a pattern element that represents a match over results of the source element.

public static PatternElement Pattern(Type type, string name, IEnumerable<KeyValuePair<string, LambdaExpression>> expressions, RuleElement? source)

Parameters

type Type

Type of elements matched by the pattern.

name string

Pattern name.

expressions IEnumerable<KeyValuePair<string, LambdaExpression>>

Expressions used by the pattern to match elements.

source RuleElement

Source of the elements matched by the pattern. If it's null, the pattern matches facts in rules engine's working memory.

Returns

PatternElement

Created element.

Project(LambdaExpression, PatternElement)

Creates an element that projects matching facts into different elements.

public static AggregateElement Project(LambdaExpression selector, PatternElement source)

Parameters

selector LambdaExpression

Expression that translates a matching element into a different element.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

Project(Type?, LambdaExpression, PatternElement)

Creates an element that projects matching facts into different elements.

public static AggregateElement Project(Type? resultType, LambdaExpression selector, PatternElement source)

Parameters

resultType Type

Type of the aggregate result.

selector LambdaExpression

Expression that translates a matching element into a different element.

source PatternElement

Pattern that matches facts for aggregation.

Returns

AggregateElement

Created element.

RuleDefinition(string, string, int, GroupElement, ActionGroupElement)

Creates a rule definition.

public static IRuleDefinition RuleDefinition(string name, string description, int priority, GroupElement leftHandSide, ActionGroupElement rightHandSide)

Parameters

name string

Rule's name.

description string

Rule's description.

priority int

Rule's priority.

leftHandSide GroupElement

Rule's left-hand side top group element.

rightHandSide ActionGroupElement

Rule's right-hand side group element.

Returns

IRuleDefinition

Created rule definition.

RuleDefinition(string, string, int, RuleRepeatability, IEnumerable<string>, IEnumerable<RuleProperty>, DependencyGroupElement, GroupElement, FilterGroupElement, ActionGroupElement)

Creates a rule definition.

public static IRuleDefinition RuleDefinition(string name, string description, int priority, RuleRepeatability repeatability, IEnumerable<string> tags, IEnumerable<RuleProperty> properties, DependencyGroupElement dependencies, GroupElement leftHandSide, FilterGroupElement filters, ActionGroupElement rightHandSide)

Parameters

name string

Rule's name.

description string

Rule's description.

priority int

Rule's priority.

repeatability RuleRepeatability

Rule's repeatability.

tags IEnumerable<string>

Tags associated with the rule.

properties IEnumerable<RuleProperty>

Properties associated with the rule.

dependencies DependencyGroupElement

Rule's dependency group element.

leftHandSide GroupElement

Rule's left-hand side top group element.

filters FilterGroupElement

Rule's filter group element.

rightHandSide ActionGroupElement

Rule's right-hand side group element.

Returns

IRuleDefinition

Created rule definition.

RuleDefinition(string, string, int, IEnumerable<string>, GroupElement, ActionGroupElement)

Creates a rule definition.

public static IRuleDefinition RuleDefinition(string name, string description, int priority, IEnumerable<string> tags, GroupElement leftHandSide, ActionGroupElement rightHandSide)

Parameters

name string

Rule's name.

description string

Rule's description.

priority int

Rule's priority.

tags IEnumerable<string>

Tags associated with the rule.

leftHandSide GroupElement

Rule's left-hand side top group element.

rightHandSide ActionGroupElement

Rule's right-hand side group element.

Returns

IRuleDefinition

Created rule definition.