Question

I am writing modular Prism application, witch is loading module files from directory (dll files). As developer I don't know how many of that modules would be in that directory, what kind of that etc.

In my application I need to get some metadata from imported modules - i.e. state (if it would be window/panel/window element/utility module), icon, localized title etc.

I know I can achieve that by creating something like Module.config file in each module, then access it in main application by ModuleInfo.Ref path (one level up -> then get Module.config file path) - but I don't want to do this that way.

I wonder if Prism got any possibility to pass metadata by code (Interface for metadata mode? XML string? Dynamic object?) If not - how can I implement it and which classes should I override?

Thank you for any advice!

Was it helpful?

Solution

If you want to exposed metadata from a module to the main application AFTER the module has been loaded and initialized then a simple approach to do this is to add the metadata of the module in its Initialize method. For example, you could have a shared service in charge of storing the metadata of the modules and each module could access it and add their metadata when their are initialized.

If you want to access the metadata of a module BEFORE it has been loaded (for example, to decide which modules you want to load or not) then Prism does not provide any functionality that could help you to do this as out of the box. You can replace the default implementation of several classes related to the interactivity API of Prism to add your custom functionality (you can read more about this here,) but for this case I think it would be better implement a separate service to obtain the metadata for the modules that would then just delegate the initialization of the modules to Prism.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top