Nuget软件包管理器仅保留一个UnityConfig.cs文件,因此我需要将它们合并,以便两个软件包都能工作。我该怎么办?
答案 0 :(得分:0)
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);
}
}
}