Print Page | Close Window

need to get Verification errors on property setters

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1654
Printed Date: 27-Mar-2025 at 10:38pm


Topic: need to get Verification errors on property setters
Posted By: downeytim
Subject: need to get Verification errors on property setters
Date Posted: 22-Feb-2010 at 6:52pm
I am running the LightHouse WPF sample.  When I open the employees panel and change the Hire Date to an invalid date I can see the error on the screen in your sample code.  I need to display all these types of verification results in a tree view control. 
 
I have about 10 different objects in play at a time in my application.  Many of the fields on these objects will have verifiers that will run on property change.  I need to capture the verification errors and place them all in a tree view.  I can't run an Instance Verification run every time a property changes so I have to get the errors from each property change.
 
How do you capture the verification error messages when the setters kick off a verification?



Replies:
Posted By: GregD
Date Posted: 26-Feb-2010 at 2:26pm
Tim:

You can do this using a VerifierBatchInterceptor. See the section in the Validation Through Verification document (in the Learning Resources) entitled, "Monitor Execution with the VerifierBatchInterceptor".

Each setter will trigger a "batch" of verifier executions (since there can potentially be multiple verifiers triggered by setting any particular property). The interceptor will get called once for each, but has an EndOfBatch flag that gets set to true when a batch is complete.  (Running an instance verification also triggers a single batch of verifier executions.)

The VerifierContext parameter for the VerifierBatchInterceptor delegate will accumulate a collection of VerifierResults for each batch. So you can check in the interceptor to see when EndOfBatch = true, then process the collection of VerifierResults to populate your tree control.




Print Page | Close Window