-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathProgram.cs
50 lines (43 loc) · 1.75 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace Rules.Framework.InMemory.Sample
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using global::Rules.Framework.InMemory.Sample.Engine;
using global::Rules.Framework.InMemory.Sample.Enums;
using global::Rules.Framework.InMemory.Sample.Helper;
using global::Rules.Framework.InMemory.Sample.Rules;
internal class Program
{
private static async Task Main(string[] args)
{
var rulesService = new RulesService(new List<IRuleSpecificationsProvider>()
{
new TestNumberRules()
});
var targetDate = DateTime.UtcNow;
while (true)
{
Console.WriteLine("Type a number and see the rule and value configured it for or use 0 to exit");
var input = Console.ReadLine().ToLower(CultureInfo.InvariantCulture);
if (int.TryParse(input, out var value))
{
if (value == 0)
{
break;
}
var conditions = new Dictionary<ConditionNames, object> {
{ ConditionNames.IsPrimeNumber, value.IsPrime() },
{ ConditionNames.CanNumberBeDividedBy3, value.CanNumberBeDividedBy3() },
{ ConditionNames.SumAll, value.SumAll() },
{ ConditionNames.RoyalNumber, value }
};
var result = await rulesService
.MatchOneAsync<string>(RulesetNames.TestNumber, targetDate, conditions);
Console.WriteLine($"The result is: {result}");
}
}
}
}
}