簡體   English   中英

UnityConfig.cs文件,同時將unity.mvc5和unity.webapi保持在同一項目中

[英]UnityConfig.cs file while keeping unity.mvc5 with unity.webapi together in the same project

Nuget軟件包管理器僅保留一個UnityConfig.cs文件,因此我需要將它們合並,以便兩個軟件包都能正常工作。 我怎樣才能做到這一點?

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM