main
 1using System;
 2
 3namespace solidware.financials.windows.ui.presenters.validation
 4{
 5    public class AnonymousRule<Severity> : Rule where Severity : validation.Severity, new()
 6    {
 7        readonly Func<bool> failCondition;
 8        readonly Func<string> errorMessage;
 9
10        public AnonymousRule(Func<bool> failCondition, Func<string> errorMessage)
11        {
12            this.failCondition = failCondition;
13            this.errorMessage = errorMessage;
14        }
15
16        public string ErrorMessage
17        {
18            get { return errorMessage(); }
19        }
20
21        public bool IsViolatedAndMoreSevereThan<OtherSeverity>() where OtherSeverity : validation.Severity, new()
22        {
23            return IsViolated() && new Severity().IsMoreSevereThan(new OtherSeverity());
24        }
25
26        public bool IsViolated()
27        {
28            return failCondition();
29        }
30    }
31}