Topics: CAB & Smart Client Software Factory
Oct 8, 2005 at 4:33 PM
originally posted by: EdJez

This is a new feature in the CAB October CTP. Any feedback would be approeciated. The purpose was to allow you to extend a workitem, without affecting its source code.

I have my app with a work item of type 'MyWorkItem'. I have made it so it exposes an interface IExtendedAddressViews with a get/set for address, and a getter for a workspace.
I can then, in another module, create a class that derives from WorkItemExtension, and attribute it with IExtendedAddressViews . The WorkItemExtension class has overrides that match the workitems lifecycle - initialize, activate, etc-. Whenever a new workitem is created in CAB that implements this IExtendedAddressViews interface, an instance of the workitem Extension will be created, added into that workitem, and the workitem lifecycle events will be hooked up to the overrides of the extension class you built.
In the extension, I could then, through the interface, get a workspace instance and show a Map view in there. That way, you can affect existing workitems without even changing thier code.

You could also do interesting things like a Journalling extension, that is attributed to affect every workitem, that logs start and end time of the workitem. That way you could easily profile how users use the app, without affecting the existing code.

I think it is a very powerful feature, thanks for the Expert Advisors who nudged us this way with suggestions. Would love to hear if/how you think it's useful.
Oct 10, 2005 at 4:43 AM
originally posted by: PProvost

There is an example of this in the BankTeller quickstart. In the CustomerMapExtensionModule you will see a class called CustomerWorkItemExtension that extends the CustomerWorkItem provided in BankTellerModule.

In this case, the extension loads a map from MSN Maps based on the customer's address.

But as Ed points out, there are lots of other interesting things that you can do with this feature.

Let us know what you think!
Dec 14, 2005 at 7:42 AM
originally posted by: danmork

Greetings. I'm having problems getting a simple WorkItemExtension to work. It seems my extension module is getting loaded after my main module has been loaded so the Activated event fires before the extension is wired up.

I've tried adding Module and ModuleDependency attributes to the two assemblies but it doesn't seem to affect the load order at all.

Any suggestions?
Dec 14, 2005 at 8:04 AM
originally posted by: danmork

Nevermind. In just a simple prototype to test the comm I was trying to extend the work item that I was loading at module init time. I needed to put that into a container work item to delay activation.
Dec 1, 2006 at 2:58 PM
originally posted by: tpattersont9

My group is currently building a UI framework that allows other business groups to "plug-in" components. Some groups have done existing work with the CAB so they have quite a bunch of existing code that would preclude us from creating our own FrameworkWorkItem and letting them extend that. I should note our framework is based on the SCSF release.

The framework creates displays and allows our business units to "host" work items in them dynamically. We would like hooks into activation/deactivation of these work items and WorkItemExtensions are nearly ideal. So we basically:
- Create a workitem and a form with a workspace (potentially many in independent windows).
- Allow other modules to host their workitems in these windows - making them children of the main workitem.
- we need to control menu and toolbar visibility when workitems are activated/deactivated/terminated.
- we would like the framework to manage this control after the hosted workitems have registered items rather than forcing the workitems to do it (so we have an abstraction in place between extension sites and use methods instead).

Unfortunately, we can't decorate a new WorkItemExtension with the "type" of the hosted workitem because we don't know it at build time. We would like to dynamically construct a WorkItemExtension when we're asked to host a workitem of a given type.

In our case, we don't even care what the specialized type is because our framework only deals with Work Items (other than to use object builder to construct the correct type).

I've looked at the bank teller quick start and assume object builder is creating the extension when the workitem is constructed.

Is there a way to dynamically create and extension or to create one for a base WorkItem class? I don't see how...

Thanks much for any feedback.
Dec 14, 2006 at 7:21 PM
originally posted by: gxdata

The mention of plugins by tpattersont9 reminds me that when reflection is used, obfuscation of the code is going to play havoc.
Was this considered when CAB was designed? What experiences and recommendations do people have?