Sharing State amongst muliple modules

Topics: CAB & Smart Client Software Factory
Jan 27, 2006 at 1:28 PM
originally posted by: dirtysanchez33

I am a little confused on how to go about designing my modules that need to share a common state. For example, the specific application i'm writing depends on selecting a customer on which all of the submodules will reference. So, when a user starts the application, they will pick a specific customer (presumably through a CustomerSelectionModule) and all of the other loaded modules (as defined in SolutionProfile.xml) will initialize themselves accordingly with this specific customer. So a module callled CustomerInfoModule would initialize itself with the customer information (name, address, etc.) and another module called the CustomerOrderModule would perhaps initalize itself with all of the orders for this customer.

In order to do this, where should I put the 'shared' Customer object. Should I have the CustomerSelectionModule (which will create the Customer object) place the Customer object in the RootWorkItem.State collection? Or is through events and pass the Customer object around? My question boils down to this:

What is the best practice for sharing a common state amongst multiple Modules?

Jan 28, 2006 at 6:05 AM
originally posted by: DLorenz

Any modules in the ProfileCatalog will automatically get run at the beginning. So all of your ModuleInit classes will run right at the beginning. Thus, when someone clicks on a customer and hits a button, you will put that object (or primary key to load the record on the other side) into state and launch the workitem(s) you need.