我的 Web 应用程序使用 UnityContainer。
我想添加策略注入。
我怎样才能同时使用它们?
意味着谁应该负责类型注册?
政策注入:
public ActionResult Index()
{
var model = PolicyInjection.Create<TestModel, ITestModel>();
ViewBag.Message = model.TestLog();
return View();
}
统一:
IUnityContainer container = defaultContainer;
//registering Unity for MVC
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
//registering Unity for web API
// GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
#region managers
container.RegisterType<ISettingsManager, SettingsManager>();
container.RegisterType<IMamDataManager, MamDataManager>();
container.RegisterType<IAppsDataManager, AppsDataManager>();
#endregion