We have several domain objects which need to support both read-only and read-write modes; they currently have a bool Locked
property for this--when Locked
attempts to alter properties on the object result in an InvalidOperationException
. The default state for the objects is Locked.
The object-initialization syntax of C# 3 introduces a small issue with these, in that the object must be unlocked (or default to be unlocked) during initialization and then locked explicityly at the end.
When using C# 3's object initialization syntax is there a means of receiving notification that the object is being intitialized or that initialization is complete? System.ComponentModel.ISupportInitialize
was my best hope, but it doesn't get called.