-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseRule.cs
42 lines (35 loc) · 911 Bytes
/
BaseRule.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
using System;
using System.Collections.Generic;
using System.Linq;
using SystemRules.RulesEngine.Interfaces;
namespace SystemRules.RulesEngine
{
public abstract class BaseRule<T> : IRule<T>
{
protected BaseRule()
{
Conditions = new List<ICondition>();
}
public IList<ICondition> Conditions { get; set; }
public void ClearConditions()
{
Conditions.Clear();
}
public bool IsValid()
{
return Conditions.All(x => x.IsSatisfied());
}
public virtual void Initialize(T obj)
{
throw new NotImplementedException();
}
public virtual T Apply(T obj)
{
throw new NotImplementedException();
}
public virtual void OnRuleViolated(T obj)
{
throw new NotImplementedException();
}
}
}