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。 –