We have the need to override IsBusy, IsSelfBusy and IsPropertyBusy in each of the business types. If i don't override it and use the new keyword instead the reintroduced properties won't be called when accessing the business object using by interface INotifyBusy.
I could ofcourse introduce an own interface and use that one, but then BusyChanged and other things are not as usefull as they are now. It's alot easier (and better imho) if the properties are marked virtual so i can override them and add my own restrictions to them.
I changed the source code in Csla myself and added virtual to the 3 properties.
Can this be changed?
I don't understand your scenario, can you explain what you are trying to do?
I don't casually make properties and methods virtual, because that just asks for disaster as people override things incorrectly. I need to understand the scenario, and make sure there isn't another less invasive solution - and frankly to make sure the scenario is compelling enough to all CSLA users to be worth the expansion of the API.
I'll try to keep it short, if u want more detail please ask.
As i implemented an custom adornerlayer as busy / loadingpanel it listens for BusyChanged events. The implementation is more complex and blocks users to access components which are databinded to a business object or it's properties. Properties can be marked as loading (being busy). I didn't use the LoadPropertyASync and instead used a custom PropertyManager instead of the LoadManager.
Anyway the overriden property IsSelfBusy adds an extra conditional requesting our LoadManager if a property is loading or not, incase it's true it will return a IsSelfBusy state true. Also the property IsPropertyBusy will need the extra conditional beside the base.IsPropertyBusy.
In the eventhandling of BusyChanged i ask if the sender impliments INotifyBusy and ask it if IsSelfBusy.
Reintroducing the properties using the new keyword won't make the being invoked.
PS: It's the BusinessBase and the ReadOnlyBase, not the Lists versions as they are already virtual there.
Oh and the code in ReadOnlyListBase has some strange comment
public override bool IsBusy
// any non-new deletions make us dirty
foreach (C item in DeletedList)
// run through all the child objects
// and if any are dirty then then
// collection is dirty
foreach (C child in this)
Do u agree to make it IsBusy and IsSelfBusy virtual?
Another option might be something like:
- add a new virtual method where additional IsBusy and IsSelfBusy conditions can be asked.
But i think this will be more complex to explain, making methods virtual is more meaningfull and a developer really should know not to override it without calling the base for sure. Right? :)
Why don't the MarkBusy and MarkIdle methods work for you?
MarkBusy on a child bubbles up the chain and every parent fires a BusyChanged where the sender can be casted to an INotifyBusy.
When getting the properties INotifyBusy.IsBusy and INotifyBusy.IsSelfBusy they will have invalid values if at least there isn't an additional condition possible either by overriding if it's virtual or by an extra function.
Oh.. and the BusyChangedEventArgs.Busy isn't enough in our case because one or more properties might be busy with being async loaded. We also added an MarkPropertyBusy and MarkPropertyIdle. Ofcourse i can choose for several another solutions like creating an own event and firing that one or creating an own interface and implement and cast to that one. But it will require testing and either way it feels like a workaround while making the IsBusy and IsSelfBusy virtual feels more pure to me.
I do understand the risk that a developer can override it in each business object, but won't that be something the developer must understand? Always call the base class.
I've the feeling i'm not clear enough
Does anyone even understand what i mean in the post above?
Sorry I didn't get back to this thread - the holiday weekend and various work things have really had me busy, and this has required some time and thought.
I do understand what you are trying to accomplish. I want to consider whether there are ways to make this more abstract conceptually. It is one thing to make the methods virtual and force everyone to implement some complex thing on their own. It is better (generally) if the concept can be abstracted and automated.
I did decide to mark the three properties/methods as virtual:
This change will be in beta 3 - thanks for the help on this issue!
Thanks, that'll make it easier for me to upgrade to a new version.
Copyright (c) Marimer LLC