views:

47

answers:

1

In the Prism Commanding_Desktop QuickStart solution, in the OrderModule, it defines a variable to the following:

this.container.Resolve<OrdersEditorPresentationModel>()

but where is this being registered so that it can be "resolved" out of the container? I see below where OrdersRepository is being registered, but I find no where in the project where OrdersEditorPresentationModel is being registered.

OrderModule.cs:

public void Initialize()
{
    this.container.RegisterType<IOrdersRepository, OrdersRepository>(new ContainerControlledLifetimeManager());

    OrdersEditorPresentationModel presentationModel = this.container.Resolve<OrdersEditorPresentationModel>();

    ...
}

OrdersEditorPresentationModel.cs:

public class OrdersEditorPresentationModel : INotifyPropertyChanged
{
    ...

    public OrdersEditorPresentationModel(OrdersEditorView view, IOrdersRepository ordersRepository, OrdersCommandProxy commandProxy)
    {
        this.ordersRepository = ordersRepository;
        this.commandProxy = commandProxy;
        this.Orders = new ObservableCollection<OrderPresentationModel>();
        this.PopulateOrders();

        this.View = view;
        view.Model = this;
    }

    ...

The constructor in the type being resolved above has a particular signature, but where is this signature being defined:

public OrdersEditorPresentationModel(OrdersEditorView view, 
        IOrdersRepository ordersRepository, 
        OrdersCommandProxy commandProxy)

I would think it might be some default signature, but another example in the Prism documentation, a presenter constructor has a different signature:

public EmployeesPresenter(IEmployeesView view, 
     IEmployeesListPresenter listPresenter,
     IEmployeesController employeeController)
+1  A: 

This type doesn't have to be declared anywhere because it is a concrete implementation. For interfaces, like say IMyInterface, that can't be instantiated automatically, you have to register a concrete implementation beforehand so that the Container knows what to instantiate when an object has a depdendency of type IMyInterface.

Anderson Imes