0

Prism Commanding_Desktop QuickStartソリューションでは、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)

デフォルトの署名である可能性があると思いますが、Prism ドキュメントの別の例では、プレゼンター コンストラクターには異なる署名があります。

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

1 に答える 1

1

この型は具体的な実装であるため、どこでも宣言する必要はありません。IMyInterfaceなど、自動的にインスタンス化できないインターフェイスの場合、オブジェクトの依存関係がIMyInterface型の場合にコンテナがインスタンス化する対象を認識できるように、事前に具体的な実装を登録する必要があります。

于 2009-07-20T17:42:12.753 に答える