2009-07-20 92 views
0

棱镜Commanding_Desktop快速启动溶液,在OrderModule,它定义了一个变量为以下:在棱镜中注册哪些类型?

this.container.Resolve<OrdersEditorPresentationModel>() 

其中这个被注册,以便它可以被“解决”从容器中?我在下面看到OrdersRepository正在注册,但我找不到在哪里项目OrdersEditorPresentationModel正在注册。

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; 
    } 

    ... 

在类型的构造上述被解决具有特定的签名,但其中是这个签名被定义为:

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

我想这可能是一些默认的签名,但棱镜文档中的另一个例子,演示构造有不同的签名

public EmployeesPresenter(IEmployeesView view, 
     IEmployeesListPresenter listPresenter, 
     IEmployeesController employeeController) 

回答

1

这种类型没有在任何地方申报因为它是一个具体的实现。对于像IMyInterface这样不能自动实例化的接口,你必须事先注册一个具体的实现,以便当对象具有IMyInterface类型的压缩时,Container知道要实例化什么。