[英]UnityConfig.cs file while keeping unity.mvc5 with unity.webapi together in the same project
Nuget package manager keeps only one UnityConfig.cs file so I need to merge both of them so that both packages work. Nuget软件包管理器仅保留一个UnityConfig.cs文件,因此我需要将它们合并,以便两个软件包都能正常工作。 How can I do this?
我怎样才能做到这一点?
using Microsoft.Practices.Unity;
using System.Web.Http;
using System.Web.Mvc;
using Unity;
namespace project_name
{
public static class UnityConfig
{
public static void RegisterComponents()
{
var container = new UnityContainer();
// register all your components with the container here
// it is NOT necessary to register your controllers
// e.g. container.RegisterType<ITestService, TestService>();
DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.