Workitem and module communication

Topics: CAB & Smart Client Software Factory
Jun 14, 2006 at 1:34 PM
originally posted by: aras03k

Hi,

I know this topic has been discussed before but I am still wrestling with an issue that I need to solve!

Suppose I have 2 modules A and B each containing a workitem. How can the A.workitem check if B.workitem is available? It would be useful if A for instance had a link label or a button on its view that would activate B. Now this button or linklabel would obviusly need to be hidden if module B is not available. In some cases the workitem that needs to be activated may not be loaded beforehand and should just be created as a child workitem when needed. In other cases events would be sufficient if I know that it is running.

I know cab has a WorkItemTypeCatalogService where i could register all my workitems, but since it stores types I would create a dependancy between the 2 modules. Should I create an interface to these "shared" workitems and then register it in the TypeCatalogService?

Thank you for your time :)
Jun 16, 2006 at 12:23 PM
originally posted by: aras03k

Update.

I'm going to go with EventBroker as the primary method of workitem communication. To aid in this i've created my own version of the WorkitemCatalogService. The biggest difference in my service and the default is that it stores types as a KeyValue pair in a dictionary. The Key is a String Id. All workitems that I want to put into my catalog is decorated with a WorkItemIdentity attribute which takes an Id string as constructor argument.

When the ModuleLoaderService fires the event ModuleLoaded, I extract all types with the Identity attribute from the module and register them with my service. When all modules have loaded I now have a full catalog of available workitems!

Whenever a workitem needs to add a childworkitem it simply calls catalogService.CreateNewWorkItem(Id, ParentWorkItem) which then returns a reference to the newly created workitem. Zero type knowledge needed.

I am going to expand my concept of a workitem catalog to enable automatic workitem loading. My requirement is that all workitems that are going to be wired up and activated by a click on a menu/toolstrip item is going to be automatically loaded. Every other workitem can either be loaded on demand or during the normal module Load();

I have a UIelementManagerService which keeps track of all menu items and their associated Commands. The UIelementmanager service gets its menu structure information from an xml file. It is then simply a question of querying the UIelementmanager for all commands and then loading all workitem types that contains those command Id's.

What do you think about this? Is this an acceptable way of handling application initialization? I Imagine that this could be further expanded to support automatic reinitialization in the event of a user logoff/logon instead of shutting the app down.