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