Delay calculation business rules execution

Delay calculation business rules execution

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


rfcdejong posted on Wednesday, July 04, 2012

Having:

- differend kind of business rules, validation and calculation.
- In a view with databinded controls with binding UpdateSourceTrigger=PropertyChanged.
- not using PropertyStatus, but instead using a customized solution looking at the brokenrules of a BO.

The nice thing about this is that business rules will be executed right after a key press and that way a validation like 'Required' is valid and marked as success. 

On the other side the calculate business rules should not calculate until the property hasn't changed for 0.5 miliseconds or so.

I looked at the Delay attribute in the WPF 4.5 Binding, but that won't execute the validation business rules either.

On the other hand, writing a custom markup extension binding it would perhaps be possible to write some generic code which also set's a property on the BO to supress calculation business rules when the delay is active, after that the calculation business rules should execute.

What would you (anyone, as the reader) recommended? All comments are welcome.

JonnyBee replied on Thursday, July 05, 2012

Hi,

With the "business object" perspective - a value is either written to the BO.Property or not.

So the BO will not know whether this happened as a PropertyChanged or Validated in the UI. 

I have no good answer for this - the BO has no knowledge of the "context" by which the property was changed. 

You could probable create your own "thread" context and Markup Extension Binding - to set the context value for PropertyChanged or Validated and then check for this is your calculation rules. However - this will have to be your own custom context and code - not supported by CSLA here. 

Copyright (c) Marimer LLC