Пример #1
0
        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>();

            container.RegisterType<UserManager<ApplicationUser>>(new HierarchicalLifetimeManager());
            container.RegisterType<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>(new HierarchicalLifetimeManager());
            container.RegisterType<DbContext, ApplicationDbContext>(new HierarchicalLifetimeManager());
            container.RegisterType<AccountController>(new InjectionConstructor());
            container.RegisterType<RolesAdminController>(new InjectionConstructor());
            container.RegisterType<UsersAdminController>(new InjectionConstructor());

            container.RegisterType<IEventServices, EventServices>();
            container.RegisterType<IShoppingCartService, ShoppingCartService>();
            container.RegisterType<IMembershipService, MembershipServices>();

            //configure/bootstrap the domain layer Automappers. this can be use if not using DI container
            //AutomapperDomainConfiguration.Configure();

            // this will register mapper profiles in this executing assembly and register Automapper as ContainerControlledLifetimeManager
            container.RegisterAutoMapperType(new ContainerControlledLifetimeManager()); 

            container.RegisterType<PortalDbContext>(new HierarchicalLifetimeManager());
            
            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }