Is it possible to add to the BrokenRulesCollection

Is it possible to add to the BrokenRulesCollection

Old forum URL: forums.lhotka.net/forums/t/9578.aspx


marthac posted on Monday, September 27, 2010

How do you add to the BrokenRulesCollection?

I see that there is a method,  AddRange(List<BrokenRule> list)

But I don't see how you can even create the list of BrokenRules because there is no constructor for the BrokenRules class and the member varaibles have no public set.

JonnyBee replied on Monday, September 27, 2010

Hi,

The BrokenRulesCollection is the result of CheckRules and contains the broken rules. You should modify or add/remove items directly to instances of this class.

marthac replied on Monday, September 27, 2010

Instances of what class? BrokenRulesCollection?

ajj3085 replied on Monday, September 27, 2010

You override AddBusinessRules, and call BusinessRules.Add.  Then as your properties change, BrokenRulesCollection is updated as the rules are run.

marthac replied on Tuesday, September 28, 2010

That's what I figured out on my own...

What I was trying to do was run external rules engine that is loaded into an Activity class.

I had to create my own BusinessRules class. Then in the Execute function I use WorkflowInvoker to invoke the Activity, then store the results in the RuleContext.

ajj3085 replied on Tuesday, September 28, 2010

I believe that's the recommended approach, and one of the reasons the rules system was reworked on Csla 4.  Glad you were able to get it working!

Copyright (c) Marimer LLC