Reputation: 663
I am making a Prism desktop application and intend to use WCF services to populate list boxes etc within views within my modules.
I have read the guide from cover to cover and have set up my solution so that I have:-
1) Shell project
2) Infrastructure Project
3) Module1
4) Module2
In Module1 I have a viewmodel that contains an ObservableCollection Customers populated by calling a WCF service directly within the view model.
I don't feel this is correct and I want to follow the Prism best practice for referencing the WCF service. The reference implementations don't really seem to be helping me in this regard.
My first attempt has been to create an interface IWCFCustomersAdapter in the Infrastructure project and have this forward on calls to the WCF service client. It is implemented in the Infrastructure project. The service reference is also added in to the Infrastructure project. Each module has a reference to the Infrastructure project and uses the datatypes defined in the WCF service.
What are the other / best choices in this circumstance? Could the interface still go in the Infrastructure project and the service references and implementation go in the modules? What are the pros and cons of the different choices?
Any tips and advice most appreciated.
Thanks
Alex
Upvotes: 1
Views: 1034
Reputation: 11760
The infrastructure module is only for infrastructure, i.e. types used to have the modules work together. These are mostly types used for communication, event aggregation, exception handling etc. I wouldn't put service adapters in there. They don't belong to infrastructure.
From my point of view a dedicated service module is a better place. If your server provides several services you can introduce a server communication module that contains all service adapters as well as the DTOs. These DTOs can also be used as models.
If your server provides quite a few services, you can split your service module into more specific ones, e.g. user management service module with session management, user management, rights management etc.
Upvotes: 2