RulesManager for WPF
Range プロパティを理解する
ルールの操作 > Range プロパティを理解する

The Range property is a collection of RulesEngineRange objects, and each object defines a subset of items, a subset of field or both. This allows the RulesManager to have control over when and where a rule should be evaluated. 

The Rule’s Ranges

Every rule has a scope determined by the Range property. This is a collection of RulesEngineRange which can be defined by a collection of fields and/or a range of items. 

Range to string conversion

For xaml and serialization purposes, there is a type-converter from string, with some specific syntax.

For instance,

Parse from a String

The Range property of a rule can be defined using the static method (Parse or TryParse).

C#
コードのコピー
rule.Ranges = RulesEngineRangeCollection.Parse(string stringValue)
// there is also constructor
rule.Ranges = new RulesEngineRangeCollection(stringValue)

Parse or TryParse methods converts a string representation of a Range into a RulesEngineRangeCollection. The string should follow the syntax rules described above (Example, "3:6:[FirstName];8:12:[LastName]").

C#
コードのコピー
// Parse a range string into Ranges collection
rule.ranges = RulesEngineRangeCollection.Parse("3:6:[FirstName];8:12:[LastName]")

Create a Range Programmatically 

Build the Range collection manually using code

C#
コードのコピー
rule.Ranges = new RulesEngineRangeCollection()
{
    new RulesEngineRange(fieldName),
    new RulesEngineRange(firstItem, lastItem, fieldName2)
    // ...
};