Rules and Scope values

Mar 18, 2015 at 5:22 AM
I have a set of rules say 1 - 50 that I wish to apply By state.

If FL use rule 1, 2, 3, and 5
If TN use rule 1, 3, and 4
If SC use rule 1, 2, and 5


How can I accomplish this? Is it possible to give rules scope values and then validate the rules based on scope?

If so how is that coded?

Thanks you for your prompt reply
Angel L. Bermudez, Jr.
Mar 19, 2015 at 6:55 AM
Edited Mar 19, 2015 at 6:55 AM

I am not entirely sure I am understanding the question... the rules apply to State or something else? I'll assume the later and therefore, you probably would use conditional construct to achieve this:
Engine engine = new Engine();
                .If(a => a.State == "FL")
                    .Setup(ph => ph.MyOtherProperty)
                        .MustPassRule(new Rule1())
                        .MustPassRule(new Rule2())
                        .MustPassRule(new Rule3())
                        .MustPassRule(new Rule5())
                .If(a => a.State == "TN")
                    .Setup(ph => ph.MyOtherProperty)
                        .MustPassRule(new Rule1())
                        .MustPassRule(new Rule3())
                        .MustPassRule(new Rule4())