Hi!

I am currently setting up a "template" project for a Winforms Application (mdi many different winfors) that will use the Model View Presenter pattern (passive view), as well as a WCF backend service that will take care of the DB-magic. I will use Unity as a IOC-container. So, let me explain my question with a simple example.

Let's say we have a simple view to show all order. I have a WCF Service with an operation

List<Order> GetAllOrders()

I have a view that implements IView called OrdersView

I have a presenter called OrderPresenter which has a constructor like this:

void OrderPresenter(IView orderView, IService service)


In the Program class I setup unity with the following steps

1) Create UnityContainer
2) Register IOrderView, IService and OrderPresenter to the container + everything else I need.


Now, my questions:

1) How should I "start"? I understand that I need a MainView with menus, splashscreens etc. And that view need a presenter. Since I might need about 20 mdi windows that will be launched from toolbar menus or a ribbon control, should I pass every single presenter as a parameter to this mainpresenter? The unitycontainer will take care of the constructors so I get the right views etc.I can see a very FAT MainPresenter that will take an object of ALL the other presenters in the application. The easiest thing would be to just pass the unity container itself into the MainPresenter, but I have been told that is an "anti pattern". Please advice how to get started!!

2) The service reference, is it OK in Program class to create an object of my WCF service and then simply put it in the unity container, and later pass it in to the MainPresenter and all other presenters as well? No problems? I am thinking lifetime, transactions, etc...


I hope the questions are clear enough, thanks in advance!

/Henrik