Is there a way to ensure a property is set?
I have set up validation which is called when a property is set. Of course, the front-end code could alway ommit to set that property. I know I can override my object's IsValid method and call ValidationRules.CheckRules(), however, if the property I'm checking is set, the ValidationRules.CheckRules() would call the same validation method, causing validation to occur twice on the same property.
Does CSLA keep track of which validation methods have been called so it does not check twice?
I sometimes override IsValid and call ValidationRules.CheckRules - but not for all properties - only for properties which are not set through the UI - or multiple properties. e.g. If I have 5 checkboxes on a form and have a rule that AtLeastOneIsChecked then I do not have a rule for each property, I have one rule which only runs after all 5 are set. (I have a web form so this is a postback and all values are posted at the same time so I only need to evaluate them once they are all set.)
CSLA does not keep track to see if a property is called twice. It allows you to call it as many times as you want/need to. That is how dependent properties work too. If you set a property and have a rule stating that another property should also be checked then all the rules for that property get checked right after this first one. But then if you Set the 2nd property the riules get re-run. That is "just the way it is". I like this style much better than the 1.x style though. It is a lot cleaner and simpler to understand.
Joe
Copyright (c) Marimer LLC