1
假設我有一個名爲IPumaServices的接口,並且我有兩個實現它的類:POSiXmlServices和TaXmlServices。如何選擇在Microsoft Unity中註冊的類型的實現
現在我有另一個名爲IPumaNotification的接口,實現它的類被稱爲PumaNotification。 PumaNotification的構造函數接收IPumaServices實現。
我的問題: 在Unity中,我該如何註冊PumaNotification的實現,它在構造器中注入POSiXmlServices,另一個注入TaXmlServices?
這是我到目前爲止。
using (_unityContainer = new UnityContainer())
{
_unityContainer
.RegisterType<IPumaServices, POSiXmlServices>("POSiXml")
.RegisterType<IPumaServices, TaXmlServices>("TaXml")
.RegisterType<IPumaNotification, PumaNotification>();
}
我不知道如何使它與我上面的要求一起工作。
我無法在線研究此問題,因爲我不確定如何描述我所面臨的問題。
我很感激任何幫助。
正是我所需要的,thnx。 –