0
的“呼叫”类
注入的具体类我有下面的代码片段团结容器,如何根据
public static void RegisterComponents(IUnityContainer container)
{
// register all your components with the container here
// it is NOT necessary to register your controllers
container.RegisterType<ISocialClient, ClientA>("a");
container.RegisterType<ISocialClient, ClientB>("b");
container.RegisterType<ISocialClient, ClientC>("c");
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
这是WebApi2项目。 所以我有3个控制器,
public class SocialAController : ApiController
{
private ISocialClient client;
...
}
是否有统一的方式来配置,为SocialAController获得“客户端A”的实施,为SocialBController获得“ClientB”执行?
谢谢,它的工作原理。 我必须添加一个构造函数到控制器 – mspasiuk