Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have a large, enterprise scale distributed application that I am working on.
 
I am using windows data-binding to generate data-bound forms for configuration quickly (in hours instead of weeks)
 
The entities that I am binding to implement INotifyPropertyChanged, and the data-binding has worked really well up to this point.
 
Due to changes in the specification and increasing row contention, I recently had to move from an optimistic locking model, to a pessimistic locking model.
 
As such, the entities are now "ReadOnly" by default, and in order to change property values, the entity must first obtain an exclusive lock on the record (which it does by a call to the server)
 
I tried implementing the IEditableObject interface, and in the BeginEdit() method I acquire the lock, and in the CancelEdit()/EndEdit() methods I release the lock.
 
This all works fine, except in the situation where a lock cannot be obtained (because another user has the same record locked)
 
If the time-out is exceeded while waiting for a lock, an ApplicationException is thrown out of the BeginEdit() method.
 
However, there doesn't seem to be any way to handle this exception, nor does there seem to be any way to communicate to the binding source that a particular entity is read-only.
 

I am considering implementing the ICustomTypeDescriptor interface, so that for a ReadOnly entity, I can yield property information that would return PropertyInfo.CanWrite as false.... but I am not sure if the windows binding framework will re-query this interface frequently enough.
 
There doesn't seem to be any support for Entities that might be in a read-only state.... (unless I have managed to miss it in the documentation???)
 
Any help, ideas, comments appreciated, specifically:
 
Is there an interface I can implement on the entity object that will communicate the read-only status of a record to the binding source, and subsequently set the bound controls to read-only (or not enabled)?
 
failing that,
 
How do you tell windows-forms-data-binding (BindingSource) that a particular record
is read-only?
 

Ta,
 
Simon B.
Posted 31-Jan-13 18:23pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 Manas Bhardwaj 319
2 Tadit Dash 285
3 OriginalGriff 273
4 Peter Leow 205
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,716
2 Peter Leow 4,345
3 Maciej Los 3,540
4 Abhinav S 3,373


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid