reset a module

Topics: CAB & Smart Client Software Factory
Aug 30, 2006 at 4:38 AM
originally posted by: jcmag

In my winform application I load some SmartParts in a Module when I click on a "Open file" menu. My problem is when the user clicks once again on this menu I need to "reset" the module, clear all Items, SmartParts... collection. How can I do this?

Thanks
Aug 30, 2006 at 4:44 AM
originally posted by: JKraft4PIT

Are you looking for a built in reset button. Something that will clear the entire module back to it's initializer?
Aug 30, 2006 at 4:50 AM
originally posted by: jcmag

yes, my "open file" button needs to reset the module back to its initialization state. (if I click on the open file button it is like a restart of the application)
Aug 30, 2006 at 5:12 AM
originally posted by: JKraft4PIT

Not that I know of, I know there isn't a way (built into CAB) to unload a Module, so if I was to "reset" a module I would do it the long way and clear all the parts.
Shouldn't be to bad, you should only have to clear the few root workitems of the module and rerun them. You may have to create a "ModuleRootWorkitem" that you can put the code in to do this.
Aug 30, 2006 at 5:35 AM
originally posted by: jcmag

I don't see "clear" methods on Items, SmartParts.. collections. Do I need to remove each element one by one??
Aug 30, 2006 at 5:51 AM
originally posted by: JKraft4PIT

It isn't a list it is a collection, they work like a Dictionary.
You will have to call remove() method for each item you want to clear.

State can be indexed in a for loop using the keys list to get the names (keys) of each state objects to remove.

But if you are up for the challenge you could add methods to the Base Classes and introduce a clear method.

This is just how I would do it. If someone has a better way, feel free to jump in.