-
Notifications
You must be signed in to change notification settings - Fork 8
Getting Started
João Romeiro edited this page Apr 23, 2023
·
3 revisions
- Define your content types (suggestion: use an enum).
internal enum ContentTypes
{
BodyMassIndexFormula = 1
}
- Define your condition types (suggestion: use an enum).
internal enum ConditionTypes
{
MassUnitOfMeasure = 1,
HeightUnitOfMeasure = 2
}
- Build a rules engine.
RulesEngine<ContentTypes, ConditionTypes> rulesEngine = RulesEngineBuilder.CreateRulesEngine()
.WithContentType<ContentTypes>() // Your content types.
.WithConditionType<ConditionTypes>() // Your condition types.
.SetDataSource(rulesDataSource) // A rules data source instance implemented by you OR using one of the available providers.
.Build();
NOTE: You should add rules before proceeding with evaluation. Please refer to add rules documentation to find out how to do that.
- Set the conditions to supply to the engine.
Condition<ConditionTypes>[] expectedConditions = new Condition<ConditionTypes>[]
{
new Condition<ConditionTypes>
{
Type = ConditionTypes.MassUnitOfMeasure,
Value = "pounds"
},
new Condition<ConditionTypes>
{
Type = ConditionTypes.HeightUnitOfMeasure,
Value = "inches"
}
};
- Set the date at which you want the rules set to evalutated.
DateTime date = new DateTime(2019, 1, 1);
- Set the content you want to fetch.
ContentTypes contentType = ContentTypes.BodyMassIndexFormula;
- Evalutate rule match.
Rule<ContentTypes, ConditionTypes> ruleMatch = await rulesEngine.MatchOneAsync(contentType, date, conditions);