protected void Application_Start() { FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); AreaRegistration.RegisterAllAreas(); #if DEBUG BundleTable.EnableOptimizations = false; //关闭文件压缩功能 #else BundleTable.EnableOptimizations = true; //开启文件压缩功能 #endif BundleConfig.RegisterBundles(BundleTable.Bundles); SysConfigModel siteConfig = new Apps.BLL.SysConfigBLL().loadConfig(Utils.GetXmlMapPath("Configpath")); //启动任务调度系统 if (siteConfig.taskstatus == 1) { StartScheduler(); } //注入 Ioc // var container = new UnityContainer(); UsingUnityContainer.Init(); DependencyRegisterType.Container_Sys(ref UsingUnityContainer._container); DependencyRegisterType.Container_Mis(ref UsingUnityContainer._container); DependencyRegisterType.Container_Def(ref UsingUnityContainer._container); DependencyRegisterType.Container_Flow(ref UsingUnityContainer._container); DependencyRegisterType.Container_Sql(ref UsingUnityContainer._container); DependencyResolver.SetResolver(new UnityDependencyResolver(UsingUnityContainer._container)); }
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>(); //GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); UsingUnityContainer.Init(); DependencyRegisterType.Container_Sys(ref UsingUnityContainer._container); GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(UsingUnityContainer._container); }