I would like to create a base FORM that can handle the basic operations of a generic BusinessBase class, such as: AddNew, Save, Cancel etc. I, typically, copy and paste the same code in my forms and I want to get away from that. The only thing I've found in the discussions about this is a posting by Andres Villanueva: http://forums.lhotka.net/forums/p/80/341.aspx using:
Public Class MustInherit MyBaseForm(Of T as BusinessBase(Of T))
...
'It can contain things such as:
'Public Property DataSource As T
'Public MustOverride Function DoSomething()
'You can also have all your security handled here, or the common save procedures
'or whatever you think you can reuse....
...
End Class
I'm thinking this maybe a good start but not sure where to go with it. Does anyone have any code they would like to share or possibly point me in the right direction?
Thanks,
Rick
As a general rule the Windows Forms technology doesn't work well with generic types - like a generic form. There are some hacks and workarounds, but it is not a core scenario that is supported by Microsoft.
There are several interfaces in CSLA 3.8+ (maybe as early as 3.6) that should allow you to create a base form that is non-generic, and which uses things like ISavable, ISupportUndo and ITrackStatus to interact with business objects regardless of their specific type.
Hi,
Take a look at the CslaActionExtender that show one way of isolating generic Save/AddNew/Cancel using the Csla Interfaces.
And if it doesn't suit your needs then make a copy and modify it....
Copyright (c) Marimer LLC