Ejemplo n.º 1
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <IDbContext>().To <DataBaseContext>().InRequestScope();
            //kernel.Bind<IDbContextFactory>().To<DbContextFactory>().InRequestScope();

            kernel.Bind <EFRepositoryFactories>().To <EFRepositoryFactories>().InSingletonScope();
            kernel.Bind <IEFRepositoryProvider>().To <EFRepositoryProvider>().InRequestScope();
            kernel.Bind <IUOW>().To <UOW>().InRequestScope();
            kernel.Bind <BaseIUOW>().To <UOW>().InRequestScope();

            kernel.Bind <IUserStore <User> >().To <UserStore>().InRequestScope();
            kernel.Bind <IRoleStore <Role> >().To <RoleStore>().InRequestScope();
            kernel.Bind <IUserStore <UserInt, int> >().To <UserStoreInt>().InRequestScope();
            kernel.Bind <IRoleStore <RoleInt, int> >().To <RoleStoreInt>().InRequestScope();

            kernel.Bind <ApplicationSignInManager>().To <ApplicationSignInManager>().InRequestScope();
            kernel.Bind <ApplicationUserManager>().To <ApplicationUserManager>().InRequestScope();
            kernel.Bind <ApplicationRoleManager>().To <ApplicationRoleManager>().InRequestScope();

            kernel.Bind <IAuthenticationManager>().ToMethod(a => HttpContext.Current.GetOwinContext().Authentication).InRequestScope();

            // http://stackoverflow.com/questions/5646820/logger-wrapper-best-practice
            kernel.Bind <NLog.ILogger>().ToMethod(a => NLog.LogManager.GetCurrentClassLogger());

            kernel.Bind <IUserNameResolver>().ToMethod(a => new UserNameResolver(UserNameFactory.GetCurrentUserNameFactory())).InRequestScope();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <IDbContext>().To <WarehouseDbContext>().InRequestScope();


            kernel.Bind <EFRepositoryFactories>().To <EFRepositoryFactories>().InSingletonScope();
            kernel.Bind <IEFRepositoryProvider>().To <EFRepositoryProvider>().InRequestScope();


            kernel.Bind <IPurchaseUOW>().To <PurchaseUOW>().InRequestScope();
            kernel.Bind <IWarehouseUOW>().To <WarehouseUOW>().InRequestScope();



            kernel.Bind <IUserStore <User> >().To <UserStore>().InRequestScope();
            kernel.Bind <IRoleStore <Role> >().To <RoleStore>();
            kernel.Bind <IUserStore <UserInt, int> >().To <UserStoreInt>().InRequestScope();
            kernel.Bind <IRoleStore <RoleInt, int> >().To <RoleStoreInt>().InRequestScope();



            kernel.Bind <ApplicationSignInManager>().To <ApplicationSignInManager>().InRequestScope();
            kernel.Bind <ApplicationUserManager>().To <ApplicationUserManager>().InRequestScope();
            kernel.Bind <ApplicationRoleManager>().To <ApplicationRoleManager>().InRequestScope();

            kernel.Bind <IAuthenticationManager>().ToMethod(a => HttpContext.Current.GetOwinContext().Authentication).InRequestScope();

            kernel.Bind <NLog.ILogger>().ToMethod(a => NLog.LogManager.GetCurrentClassLogger());

            kernel.Bind <IUserNameResolver>().ToMethod(a => new UserNameResolver(UserNameFactory.GetCurrentUserNameFactory())).InSingletonScope();
        }