Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // RegisterDependency就是注册接口与实例的关系.
            // setCongrollerFactory则是用MyDependencyMvcControllerFactory替代默认Controller工厂

            DependencyFactory.RegisterDependency();

            ControllerBuilder.Current.SetControllerFactory(new DependencyMvcControllerFactory());

            GlobalConfiguration.Configuration.DependencyResolver = new IoCContainer(DependencyUnityContainer.Current);
            //var builder = new ContainerBuilder();
            //var data = Assembly.Load("Service");
            //builder.RegisterAssemblyTypes(data)
            //      .Where(a => a.FullName.Contains("SqlServer")).AsImplementedInterfaces();
            //builder.RegisterControllers(Assembly.GetExecutingAssembly());
            //var container = builder.Build();
            //DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Ejemplo n.º 2
0
        public override async Task Initialize()
        {
            DependencyFactory.RegisterDependency <ILocaleProvider>(this);

            await base.Initialize();

            Add("Languages");

            currentLocale  = Locales[FallbackCulture];
            fallbackLocale = currentLocale;
        }
Ejemplo n.º 3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // RegisterDependency就是注册接口与实例的关系.
            // setCongrollerFactory则是用MyDependencyMvcControllerFactory替代默认Controller工厂
            DependencyFactory.RegisterDependency();
            //ICO MVC注册
            ControllerBuilder.Current.SetControllerFactory(new DependencyMvcControllerFactory());
            //ICO API注册
            GlobalConfiguration.Configuration.DependencyResolver = new IoCContainer(DependencyUnityContainer.Current);
        }