How To Discover Service in Module?

Topics: Prism v4 - WPF 4
Nov 21, 2010 at 12:09 AM

Dear Sir,

We are writing a compsite application, this app just a 'Shell' and other team will write 'plug-in' for this app. We plan to implement these 'plug-ins' as module and put them in a specific folder. We meet 2 problems.

1. How to get the services in the module? After we get the ModuleInfo instance, we don't know how to deal with them.
2. Each plug-in should implement a interface IBookLibrary, in this interface there's method 'List<string> GetAllBookNames()'. The problem is: where we should put this interface? Shell project or plug-in projects or another isolated project?

Thanks and Regards,

Nov 23, 2010 at 3:20 PM

Hi Tim,

When consuming a service from a module, you shouldn't explicitly get a reference to the ModuleInfo. To achieve loose-coupling between your modules, you should expose the services as Shared Services, or use any other way of communication between loosely coupled components.

As for the interfaces for the services, you could place them in an infrastructure module, as it is done in the Stock Trader Reference Implementation. From the documentation:

In the Stock Trader Reference Implementation (Stock Trader RI), the Market module provides an implementation of IMarketFeedService. The Position module consumes these services by using the shell application's dependency injection container, which provides service location and resolution. The IMarketFeedService is meant to be consumed by other modules, so it can be found in the StockTraderRI.Infrastructure common assembly, but the concrete implementation of this interface does not need to be shared, so it is defined directly in the Market module and can be updated independently of other modules.

I hope you find this helpful.

Guido Leandro Maliandi