/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> private static void RegisterTypes(IUnityContainer container) { // register global dependencies WebBootstrapper.SetupDependency(container); RepositoryBootstrapper.SetupDependency(container); ServiceBootstrapper.SetupDependency(container); // register owin dependencies container.RegisterType <IRoleStore <Role, int>, RoleStore <Role, int, UserRoles> >(); container.RegisterType <IUserStore <User, int>, UserStore <User, Role, int, UserLogins, UserRoles, UserClaims> >(); container.RegisterType <IAuthenticationManager>(new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication)); // register inner app dependencies container.RegisterType <EoraUserManager>(); container.RegisterType <EoraSignInManager>(); }
/// <summary> /// Configurations the specified application. /// </summary> /// <param name="app">The application.</param> public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); #region Container var container = DependencyInjectionContainerFactory.Create(); DataAccessBootstrapper.Bootstrap(container); RepositoryBootstrapper.Bootstrap(container); ServiceBoostrapper.Bootstrap(container); WebApiBootstrapper.Bootstrap(container); container.RegisterWebApiControllers(config); #if DEBUG container.Verify(); #endif config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); #endregion Container app.UseOwinContextExecutionScope(container); #region OAuth app.UseDefaultOAuthAuthorizationServer(container); app.UseDefaultOAuthBearerAuthentication(container); #endregion OAuth #region Web Api app.UseOwinContextProvider(); app.UseCors(CorsOptions.AllowAll); WebApiConfig.Register(config); app.UseWebApi(config); #endregion Web Api }