Listing available modules in a list

Topics: Prism v2 - WPF 3.5
Mar 1, 2010 at 11:27 PM

Here follows a brief description on basically what I want my application to do:
I'm going to create an application which will be used to facilitate adventuremaking in "Paper and Pen RPG" context (yeah I know, I'm a nerd). This application is meant to have support for, in principle, any kind of RPG.
Therefore is the need to load different M-V-VM modules based on the selected RPG. The "product" of a module will always be an adventure.

The thing is that when a new Campaign is created I want to show a list of all available RPGs (modules) without loading the assemblys, which after a while can become quite many.  
I could probably (if I understand MEF correctly) do this the Lazy way with MEF and just read the metadata, but I rather not mix MEF with Prism unless necessary. But if that's the only way then so be it.

Is it possible, in some relatively simple way, to do this with Prism only?
If not, then what would be the best approach to achieve this?

Thanks in advance!
Fredrik E 

Mar 4, 2010 at 7:42 PM
Edited Mar 4, 2010 at 7:43 PM

Hi Fredrik,

One possible way to achieve this kind of behavior is have all the RPG modules load on demand. That way the view that is in charge of showing the available RPG modules can get injected in its ViewModel with an instance of IModuleCatalog to get all module names without loading all the modules. The code below can be used to get the list of module names (you probably will use a Property in the VM to hold the views’ names):

List<string> moduleNames = new List<string>();
catalog.Modules.ToList().ForEach(m => moduleNames.Add(m.ModuleName));

After that you can load the module on demand based on the user’s selection.

Please let me know if this helps.

Damian Schenkelman

Mar 5, 2010 at 2:13 AM

Sweet! That looks about what I've been looking around for in the www these past days. I'll throw in a quick update later next week or the week after that when I've started up the project and tried this.
Anyways, for now, many thanks! =)