Example #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(x =>
            {
                x.FromThisAssembly()     // Scans currently assembly
                .SelectAllClasses()      // Retrieve all non-abstract classes

                .BindDefaultInterface(); // Binds the default interface to them;
            });
            kernel.Bind <IDbContext>().To <AppDbContext>().InRequestScope();
            //    kernel.Bind<IDbContext>().To<AppDbContext>();

            /*   kernel.Bind<IProductService>().To<ProductService>();
             * kernel.Bind<IPartnerService>().To<PartnerService>();
             * kernel.Bind<ILogger>().To<Logger>();  */

            kernel.BindFilter <MyActionFilterAttribute>(FilterScope.Global, 1).InRequestScope();
            kernel.BindFilter <LoggedExceptionFilter>(FilterScope.Global, 2).InRequestScope();

            kernel.Rebind <ICacheService>().To <CacheService>().InSingletonScope();
            // kernel.Bind<ICacheService>().To<CacheService>().InSingletonScope();

            kernel.Bind <HttpContextBase>().ToMethod(c => new HttpContextWrapper(HttpContext.Current));

            kernel.BindFilter <LogFilter>(FilterScope.Controller, 0).WhenControllerType <HomeController>().WithConstructorArgument("IDbContext", (p) => p.Kernel.Get <IDbContext>());
            //.WithConstructorArgument("logLevel", ("Info"));
        }
Example #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 <IGameService>().To <GameService>();
            kernel.Bind <IGenreService>().To <GenreService>();
            kernel.Bind <ICommentService>().To <CommentService>();
            kernel.Bind <IPlatformTypeService>().To <PlatformTypeService>();
            kernel.Bind <IBasketService>().To <BasketService>();
            kernel.Bind <IPublisherService>().To <PublisherService>();
            kernel.Bind <IOrderService>().To <OrderService>();
            kernel.Bind <IPaymentService>().To <PaymentService>();
            kernel.Bind <IUserService>().To <UserService>();
            kernel.Bind <IRoleService>().To <RoleService>();
            kernel.Bind <ILanguageService>().To <LanguageService>();

            kernel.Bind <IPipeline <GameFilterContainer> >().To <Pipeline <GameFilterContainer> >();
            kernel.Bind <IFilter <GameFilterContainer> >().To <BaseFilter <GameFilterContainer> >();

            kernel.Bind <IUnitOfWork>().To <UnitOfWork>().InSingletonScope();

            kernel.Bind <IDbSynchronizer>().To <DbSynchronizer>();

            kernel.Bind <ILogger>().To <GameStoreLogger>();

            kernel.BindFilter <PerformanceLoggingFilter>(FilterScope.Global, 0);
            kernel.BindFilter <ExceptionLoggingFilter>(FilterScope.Global, 0);
        }
Example #3
0
        private void AddBindings()
        {
            _kernel.Bind <IQuestionRepository>().To <DbQuestionRepository>()
            .WithConstructorArgument("context", new LoggerContext());
            _kernel.Bind <IGameStepRepository>().To <JsonGameStepRepository>()
            .WithConstructorArgument("filename", HostingEnvironment.MapPath(ConfigurationManager.AppSettings["GameStepsPath"]));
            _kernel.Bind <IPlayerStatisticsReporitory>().To <DbPlayerStatisticsRepository>()
            .WithConstructorArgument("context", new LoggerContext());

            _kernel.Bind <IEncryptionService>().To <AESEncryptionService>().WithConstructorArgument("encryptionKey", "abc123");
            _kernel.Bind <IMessageService>().To <EmailClient>().WithConstructorArgument("encryptionService", _kernel.Get <IEncryptionService>());

            _kernel.Bind <IQuestionStatisticRepository>().To <DbQuestionStatisticRepository>()
            .WithConstructorArgument("context", new LoggerContext());
            _kernel.Bind <IGameHint>().To <GameHint>().WithConstructorArgument("messageService", _kernel.Get <IMessageService>())
            .WithConstructorArgument("questionStatisticRepository", _kernel.Get <IQuestionStatisticRepository>());

            _kernel.Bind <IExceptionDetailRepository>().To <DbExceptionDetailRepository>().WithConstructorArgument("context",
                                                                                                                   new LoggerContext());

            _kernel.BindFilter <ExceptionLoggerFilter>(FilterScope.Controller, 0)
            .WhenControllerHas <ExceptionLoggerAttribute>()
            .WithConstructorArgument("repository", _kernel.Get <IExceptionDetailRepository>());    //logger injection
            _kernel.BindFilter <ActionLoggerFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <ActionLoggerAttribute>()
            .WithConstructorArgument("repository", _kernel.Get <IQuestionStatisticRepository>());
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel
            .BindFilter <SecureConnectionAttribute>(FilterScope.Global, 0);

            kernel
            .BindFilter <HandleErrorAttribute>(FilterScope.Global, 1);

            kernel
            .BindFilter <ApplicationSettingsAttribute>(FilterScope.Global, 2);

            kernel
            .BindFilter <MailSettingsAttribute>(FilterScope.Global, 3);

            kernel
            .Bind <ApplicationSettings>()
            .ToMethod(context => new ApplicationSettings(ConfigurationManager.AppSettings))
            .InRequestScope();

            kernel
            .Bind <MailSettings>()
            .ToMethod(context => {
                var configurationFile = WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath);
                var mailSettings      = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;

                return
                (mailSettings == null
                                                        ? null
                                                        : new MailSettings(mailSettings.Smtp));
            })
            .InRequestScope();

            kernel.Load <PersistenceModule>();
        }
Example #5
0
 private static void BindAttributeAndFilter <TFilter, TAttribute>(this IKernel kernel)
 {
     kernel.BindFilter <TFilter>(FilterScope.Action, null)
     .WhenControllerHas <TAttribute>();
     kernel.BindFilter <TFilter>(FilterScope.Action, null)
     .WhenActionMethodHas <TAttribute>();
 }
Example #6
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter<FilterAlpha>(FilterScope.Controller, 0)
                .WhenControllerHas<AlphaAttribute>();

            //kernel.BindFilter<FilterAlpha>(FilterScope.Global, 0);
            kernel.BindFilter<FilterBeta>(FilterScope.Global, 0);
        }
Example #7
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter <LocalOnlyRequestFilter>(FilterScope.Controller, 0)
            .WhenControllerHas <LocalOnlyRequestAttribute>();

            kernel.BindFilter <LocalOnlyRequestFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <LocalOnlyRequestAttribute>();
        }
Example #8
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter<LocalOnlyRequestFilter>(FilterScope.Controller, 0)
                .WhenControllerHas<LocalOnlyRequestAttribute>();

            kernel.BindFilter<LocalOnlyRequestFilter>(FilterScope.Action, 0)
                .WhenActionMethodHas<LocalOnlyRequestAttribute>();
        }
Example #9
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter <FilterAlpha>(FilterScope.Controller, 0)
            .WhenControllerHas <AlphaAttribute>();

            //kernel.BindFilter<FilterAlpha>(FilterScope.Global, 0);
            kernel.BindFilter <FilterBeta>(FilterScope.Global, 0);
        }
Example #10
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<Database>()
            .ToMethod(c => new PetaPoco.Database("GrokMob"))
            .InRequestScope();

              kernel.BindFilter<StatsViewDataAttribute>(FilterScope.Global, 0);
              kernel.BindFilter<UserViewDataAttribute>(FilterScope.Global, 0);
        }
Example #11
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<ILogger>().To<NLogger>().InSingletonScope();
     kernel.Bind<IIdStore>().To<FormsAuthIdStore>();
     kernel.Bind<IBackgroundJobManager>().To<BackgroundJobManager>().InSingletonScope();
     kernel.Bind<ISchedulerFactory>().To<StdSchedulerFactory>().InSingletonScope();
     kernel.Bind<IScheduler>().ToMethod(context => context.Kernel.Get<ISchedulerFactory>().GetScheduler()).InSingletonScope();
     kernel.BindFilter<VerifyClickThruAttribute>(FilterScope.Controller, 0);
     kernel.BindFilter<ForcePasswordChangeAttribute>(FilterScope.Controller, 1);
 }
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind<ICarData>().To<CarData>();
     kernel.Bind<ICarDbContext>().To<CarDbContext>();
     kernel.Bind<ICacheService>().To<CarsCacheService>();
     kernel.BindFilter<CheckIsAllowedForEditingCar>(FilterScope.Controller, int.MaxValue)
         .WhenControllerHas<CheckIsAllowedForEditingCar>();
     kernel.BindFilter<CheckIsAllowedForEditingCar>(FilterScope.Action, int.MaxValue)
         .WhenControllerHas<CheckIsAllowedForEditingCar>();
 }
Example #13
0
        public void Register(IKernel kernel)
        {
            kernel.BindFilter <ProductsCategoriesCacheFilter>(FilterScope.Action, 0)
            .When((controllerContext, actionDescriptor) => actionDescriptor
                  .GetCustomAttributes(typeof(PopulateFromCacheAttribute), true)
                  .Any(attr => ((PopulateFromCacheAttribute)attr).ViewBagPropIds.Contains(CacheIds.ProductCategories)));

            kernel.BindFilter <ProductsCategoriesDropDownFilter>(FilterScope.Action, 0)
            .When((controllerContext, actionDescriptor) => actionDescriptor
                  .GetCustomAttributes(typeof(PopulateFromCacheAttribute), true)
                  .Any(attr => ((PopulateFromCacheAttribute)attr).ViewBagPropIds.Contains(CacheIds.ProductCategoriesDropDown)));
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // service interfaces
            kernel.Bind <IWarcraftSession>()
            .To <WarcraftSession>()
            .InRequestScope();

            // filter bindings
            kernel.BindFilter <IsAdminFilter>(FilterScope.Action, 0);
            kernel.BindFilter <AuthorizeAdminFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <AuthorizeAdminAttribute>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // service interfaces
            kernel.Bind<IWarcraftSession>()
                  .To<WarcraftSession>()
                  .InRequestScope();

            // filter bindings
            kernel.BindFilter<IsAdminFilter>(FilterScope.Action, 0);
            kernel.BindFilter<AuthorizeAdminFilter>(FilterScope.Action, 0)
                  .WhenActionMethodHas<AuthorizeAdminAttribute>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <ILockStore>().To <LockStore>();

            kernel
            .BindFilter <TakesALockFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <TakesALockAttribute>();

            kernel
            .BindFilter <ReleasesALockFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <ReleasesALockAttribute>();
        }
Example #17
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 <ILog>().To <SqlLog>();
     kernel.Bind <IContextProvider>().To <GenericContextProvider>().InRequestScope();
     kernel.Bind <IRegisterViewModelMapper>().To <RegisterViewModelMapper>();
     kernel.Bind <IMakeViewModelMapper>().To <MakeViewModelMapper>();
     kernel.Bind <IGetPendingForVehicleViewModelMapper>().To <GetPendingForVehicleViewModelMapper>();
     kernel.Bind <IUserProvider>().To <UserProvider>();
     kernel.Bind <IIndexViewModelMapper>().To <IndexViewModelMapper>();
     kernel.BindFilter <EntityFrameworkWriteContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas <EntityFrameworkWriteContextAttribute>();
     kernel.BindFilter <EntityFrameworkReadContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas <EntityFrameworkReadContextAttribute>();
     kernel.BindFilter <LogFilter>(FilterScope.Action, 1050).WhenActionMethodHas <LogAttribute>();
     new DataRegistry().RegisterServices(kernel);
 }
		/// <summary>
		/// Load your modules or register your services here!
		/// </summary>
		/// <param name="kernel">The kernel.</param>
		private static void RegisterServices(IKernel kernel)
		{
			kernel.BindFilter<AuthorizeFilter>(FilterScope.Controller, 0)
				.WhenControllerHas<YmirAuthorizeAttribute>()
				.WithConstructorArgumentFromControllerAttribute<YmirAuthorizeAttribute>("requiredPermissions", attribute => attribute.RequiredAccess);
			kernel.BindFilter<AuthorizeFilter>(FilterScope.Controller, 0)
				.WhenActionMethodHas<YmirAuthorizeAttribute>()
				.WithConstructorArgumentFromActionAttribute<YmirAuthorizeAttribute>("requiredPermissions", attribute => attribute.RequiredAccess);

			kernel.Bind<IAuthenticationService>().To<AuthenticationService>().InRequestScope();
			// kernel.Bind<IClientService>().To<ClientService>().InRequestScope();

			Debug(kernel);
		}
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind <ILog>().To <SqlLog>();
     kernel.Bind <IEmailer>().To <StubEmailer>();
     kernel.Bind <IContextProvider>().To <GenericContextProvider>().InRequestScope();
     kernel.Bind <ICollectViewModelMapper>().To <CollectViewModelMapper>();
     kernel.Bind <IReturnViewModelMapper>().To <ReturnViewModelMapper>();
     kernel.Bind <IGetSummaryViewModelMapper>().To <GetSummaryViewModelMapper>();
     kernel.Bind <IGenerateViewModelMapper>().To <GenerateViewModelMapper>();
     kernel.Bind <IUserProvider>().To <UserProvider>();
     kernel.BindFilter <EntityFrameworkWriteContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas <EntityFrameworkWriteContextAttribute>();
     kernel.BindFilter <EntityFrameworkReadContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas <EntityFrameworkReadContextAttribute>();
     kernel.BindFilter <LogFilter>(FilterScope.Action, 1050).WhenActionMethodHas <LogAttribute>();
     new DataRegistry().RegisterServices(kernel);
 }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind(x =>
            {
                x.FromThisAssembly()
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(x =>
            {
                x.FromAssemblyContaining(typeof(IBookService))
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(typeof(DbContext), typeof(LibrarySystemDbContext)).To <LibrarySystemDbContext>()
            .InRequestScope();
            kernel.Bind(typeof(IEfRepostory <>)).To(typeof(EfRepostory <>)).InRequestScope();
            kernel.Bind <IEfUnitOfWork>().To <EfUnitOfWork>().InRequestScope();

            var context = kernel.Bind <HttpContext>().ToMethod(c => HttpContext.Current);

            kernel.Bind <HttpContextBase>().To <HttpContextWrapper>().WithConstructorArgument(context);

            kernel.BindFilter <SaveChangesFilter>(FilterScope.Controller, 0).WhenActionMethodHas <SaveChangesAttribute>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind(x =>
            {
                x.FromThisAssembly()
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(x =>
            {
                x.FromAssemblyContaining(typeof(IDataService))
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(x =>
            {
                x.FromAssemblyContaining(typeof(IService))
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel
            .Bind(typeof(DbContext), typeof(MsSqlDbContext))
            .To <MsSqlDbContext>()
            .InRequestScope();

            kernel.Bind <ISaveContext>().To <SaveContext>().InRequestScope();
            kernel.Bind(typeof(IEfRepository <>)).To(typeof(EfRepository <>)).InRequestScope();

            // kernel.BindFilter<SaveChangesFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenActionMethodHas<SaveChangesAttribute>();
            kernel.BindFilter <SaveChangesFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas <SaveChangesAttribute>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Load <NoiseCalculatorModule>();
            kernel.Load <NoiseCalculatorWebModule>();

            kernel.BindFilter <CustomAuthorizeFilter>(FilterScope.Controller, 0).WhenControllerHas <CustomAuthorizeAttribute>();
        }
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind<EntidadesContext>().ToSelf().InRequestScope();
     // registro dos outros componentes
     int ordemExecucao = 1;
     kernel.BindFilter<SaveChangesFilter>(FilterScope.Global, ordemExecucao);
 }       
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <ISession>();
            int ordemExecucao = 1;

            kernel.BindFilter <TransactionFilter>(FilterScope.Global, ordemExecucao);
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <IContentProvider>().To <AzureProvider>();

            kernel.Bind <IBrandRepository>().To <BrandRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <IVehiclTypeRepository>().To <VehiclTypeRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <IFuelRepository>().To <FuelRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <ITransmissionTypeRepository>().To <TransmissionTypeRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <IAdvertisementRepository>().To <AdvertisementRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <IRegionRepository>().To <RegionRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);
            kernel.Bind <ICurrencyRepository>().To <CurrencyRepository>()
            .WithConstructorArgument("connectionString", ConnectionStringBuilder.ConnectionString);

            kernel.Bind <IUserStore <IdentityUser> >().To <UserStore <IdentityUser> >();

            kernel.Bind <IAdvertisementSearchQueryBuilder>().To <AdvertismentRepositoryLinqExpressions>();

            kernel.BindFilter <ExceptionLoggingFilterAttribute>(FilterScope.Global, 0);
        }
Example #26
0
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind(x =>
            {
                x.FromThisAssembly()
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(x =>
            {
                x.FromAssemblyContaining(typeof(IUserService))
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            kernel.Bind(typeof(DbContext), typeof(EfDbContext)).To <EfDbContext>().InRequestScope();
            kernel.Bind(typeof(IEfDbSetWrapper <>)).To(typeof(EfDbSetWrapper <>));
            kernel.Bind(typeof(IEfDbContextSaveChanges)).To(typeof(EfDbContextSaveChanges));

            kernel.Bind <IApplicationSignInManager>().ToMethod(_ => HttpContext.Current.GetOwinContext().Get <ApplicationSignInManager>());
            kernel.Bind <IApplicationUserManager>().ToMethod(_ => HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>());

            kernel.BindFilter <SaveChangesFilter>(FilterScope.Controller, 0).WhenActionMethodHas <SaveChangesAttribute>();
        }
Example #27
0
        private static void RegisterServices(IKernel kernel)
        {
            var productsUri = ConfigurationManager.AppSettings.Get("ProductsUri");
            var usersUri    = ConfigurationManager.AppSettings.Get("UsersUri");


            kernel.Bind <Domain.Abstract.IProductRepository>().To <Domain.Concrete.ProductRepository>()
            .WithConstructorArgument("httpClient", new HttpClient())
            .WithConstructorArgument("uri", new Uri(productsUri))
            .WithConstructorArgument("cacheHandler", new Domain.Concrete.InMemoryCache(300000));

            kernel.Bind <Domain.Abstract.IUserRepository>().To <Domain.Concrete.UserRepository>()
            .WithConstructorArgument("httpClient", new HttpClient())
            .WithConstructorArgument("uri", new Uri(usersUri));

            kernel.Bind <Domain.Abstract.IOrderProcessor>().To <Domain.Concrete.EmailOrderProcessor>()
            .WithConstructorArgument("settings", new Domain.Entities.EmailSettings());

            kernel.BindFilter <Attributes.CustomAuthorize>(FilterScope.Action, 0).When(
                (controllerContext, actionDescriptor) => string.Equals(controllerContext.RouteData.GetRequiredString("controller"), "admin", StringComparison.OrdinalIgnoreCase));


            //Moq.Mock<Domain.Abstract.IProductRepository> mock = new Moq.Mock<Domain.Abstract.IProductRepository>();
            //mock.Setup(m => m.Products).Returns(new List<Domain.Entities.Product>
            //{
            //    new Domain.Entities.Product {ProductId = 99,Name="TankTop T",Price = 22.6M, Description="Mens Black TankTop T-Shirt",Category="Clothing" },
            //    new Domain.Entities.Product {ProductId = 99,Name="T-Shirt",Price = 22.6M, Description="Mens White T-Shirt",Category="Clothing" },
            //    new Domain.Entities.Product {ProductId = 99,Name="T-Shirt",Price = 22.6M, Description="Mens Black T-Shirt",Category="Clothing" }
            //});
            //kernel.Bind<Domain.Abstract.IProductRepository>().ToConstant(mock.Object);
        }
Example #28
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 <ISession>().ToMethod(x => NHibernateHelper.AbreSession()).InRequestScope();
            int ordemExecucao = 1;

            kernel.BindFilter <TransactionFilter>(FilterScope.Global, ordemExecucao);
        }
Example #29
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // Bind local services
            kernel.Bind <IEmployeeServices>().To <EmployeeServices>();
            kernel.Bind <IRoleServices>().To <RoleServices>();
            kernel.Bind <IPermissionServices>().To <PermissionServices>();
            kernel.Bind <ILogServices>().To <LogServices>();
            kernel.Bind <IPostServices>().To <PostServices>();
            kernel.Bind <IPostExtraPaymentServices>().To <PostExtraPaymentServices>();
            kernel.Bind <IWebsiteServices>().To <WebsiteServices>();
            kernel.Bind <IInvoiceServices>().To <InvoiceServices>();
            kernel.Bind <IMessageServices>().To <MessageServices>();
            kernel.Bind <INotificationServices>().To <NotificationServices>();

            // App Data & Infrastructure modules
            var modules = new List <NinjectModule>
            {
                new RepositoryModule(),
                new HelperModule()
            };

            kernel.BindFilter <UnitOfWorkFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <UnitOfWorkFilter>()
            .InRequestScope();
            kernel.Load(modules);
        }
Example #30
0
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Load(Assembly.GetExecutingAssembly());
     kernel.Bind <ContextProvider>()
     .To <ContextProvider>()
     .InRequestScope()
     .WithConstructorArgument("connectionStringName", "DefaultConnection");
     kernel.Bind <IUnitOfWorkFactory>().To <UnitOfWorkFactory>().InRequestScope();
     kernel.Bind <IAuthenticationService>().To <AuthenticationService>().InRequestScope();
     kernel.Bind <IOAuthInintializer>()
     .To <OAuthInintializer>()
     .InRequestScope();
     kernel.Bind <IUserRegistrationService>().To <UserRegistrationService>().InRequestScope();
     kernel.Bind <IUserRepository>().To <UserRepository>().InRequestScope();
     kernel.Bind <IRoleRepository>().To <RoleRepository>().InRequestScope();
     kernel.Bind <IUserDataRepository>().To <UserDataRepository>().InRequestScope();
     kernel.Bind <INewsRepository>().To <NewsRepository>().InRequestScope();
     kernel.Bind <INewsTextRepository>().To <NewsTextRepository>().InRequestScope();
     kernel.Bind <IMembershipRepository>().To <MembershipRepository>().InRequestScope();
     kernel.Bind <IOAuthMembershipRepository>().To <OAuthMembershipRepository>().InRequestScope();
     kernel.Bind <IRoleProvider>().To <RoleProvider>().InRequestScope();
     kernel.Bind <IOAuthService>().To <OAuthService>().InRequestScope();
     kernel.Bind <INewsLogic>().To <NewsLogic>().InRequestScope();
     kernel.Bind <IAccountLogic>().To <AccountLogic>().InRequestScope();
     kernel.BindFilter <AdministratorOnlyFilter>(FilterScope.Action, 0).WhenActionMethodHas <AdministratorOnlyAttribute>();
 }
 public NinjectDependencyResolver(IKernel kernel)
 {
     _kernel = kernel;
     _kernel.ConfigurateResolverWeb();
     _kernel.BindFilter <Filters.AuthorizeAttribute>(FilterScope.Controller, null)
     .WhenControllerHas <Filters.AuthorizeAttribute>();
 }
Example #32
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 <IConfiguration>().To <Configuration>();
            kernel.Bind <ILoggingService>().To <LoggingService>();
            kernel.Bind <IAuthenticationService>().To <AuthenticationService>();
            kernel.Bind <ICurrentUser>().To <CurrentUser>();
            kernel.Bind <IGiftRepository>().To <GiftRepository>();
            kernel.Bind <IFeedbackRepository>().To <FeedbackRepository>();
            kernel.Bind <IUserRepository>().To <UserRepository>();
            kernel.Bind <IUserManager>().To <UserManager>();
            kernel.Bind <IRegistryManager>().To <RegistryManager>();
            kernel.Bind <IMailService>().To <MailService>();
            kernel.Bind <IFeedbackManager>().To <FeedbackManager>();

            kernel.BindFilter <HandleAllTheThingsAttribute>(System.Web.Mvc.FilterScope.Controller, 0);
            kernel.BindFilter <AuthorizeAdminUserFilter>(FilterScope.Action, 0).WhenActionMethodHas <AuthorizeAdminUserAttribute>();
        }
Example #33
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<IConfiguration>().To<Configuration>();
            kernel.Bind<ILoggingService>().To<LoggingService>();
            kernel.Bind<IAuthenticationService>().To<AuthenticationService>();
            kernel.Bind<ICurrentUser>().To<CurrentUser>();
            kernel.Bind<IGiftRepository>().To<GiftRepository>();
            kernel.Bind<IFeedbackRepository>().To<FeedbackRepository>();
            kernel.Bind<IUserRepository>().To<UserRepository>();
            kernel.Bind<IUserManager>().To<UserManager>();
            kernel.Bind<IRegistryManager>().To<RegistryManager>();
            kernel.Bind<IMailService>().To<MailService>();
            kernel.Bind<IFeedbackManager>().To<FeedbackManager>();

            kernel.BindFilter<HandleAllTheThingsAttribute>(System.Web.Mvc.FilterScope.Controller, 0);
            kernel.BindFilter<AuthorizeAdminUserFilter>(FilterScope.Action, 0).WhenActionMethodHas<AuthorizeAdminUserAttribute>();
        }
Example #34
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<ISession>().ToMethod(x => NHibernateHelper.AbreSession()).InRequestScope();

            // registro dos outros componentes
            int ordemExecucao = 1;
            kernel.BindFilter<TransactionFilter>(FilterScope.Global, ordemExecucao);
        }
Example #35
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(scanner => scanner.FromAssembliesMatching("Sfw.Sabp.Mca.*")
                        .SelectAllClasses().NotInNamespaces(new[] { "Sfw.Sabp.Mca.Web.ViewModels.Validation" })
                        .BindAllInterfaces());

            kernel.Bind <DbContext>().To <DataAccess.Ef.Mca>().InRequestScope();

            kernel.Rebind <IUnitOfWork>().To <UnitOfWork>()
            .InRequestScope()
            .WithConstructorArgument(new DataAccess.Ef.Mca());

            kernel.BindFilter <AuthorizeMcaUsersAttribute>(FilterScope.Global, 0);
            kernel.BindFilter <ErrorLoggerFilter>(FilterScope.Global, 0);

            kernel.BindFilter <AuditFilterAttribute>(FilterScope.Action, 0).WhenActionMethodHas <AuditAttribute>()
            .WithConstructorArgumentFromActionAttribute <AuditAttribute>("auditProperties", x => x.AuditProperties);

            kernel.BindFilter <AssessmentInProgressActionFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <AssessmentInProgressAttribute>()
            .WithConstructorArgumentFromActionAttribute <AssessmentInProgressAttribute>("actionParameterId", x => x.ActionParameterId);

            kernel.BindFilter <AssessmentCompleteActionFilter>(FilterScope.Action, 0)
            .WhenActionMethodHas <AssessmentCompleteAttribute>()
            .WithConstructorArgumentFromActionAttribute <AssessmentCompleteAttribute>("actionParameterId", x => x.ActionParameterId);

            kernel.BindFilter <AgreedToDisclaimerAuthorizeAttribute>(FilterScope.Controller, 0).WhenControllerHas <AgreedToDisclaimerAuthorizeAttributeNinject>();

            kernel.BindFilter <AuthorizeAdministratorAttribute>(FilterScope.Action, 0).WhenActionMethodHas <AuthorizeAdministratorAttributeNinject>();

            kernel.Rebind <ModelMetadataProvider>().To <CustomModelMetadataProvider>().InSingletonScope();

            AssemblyScanner.FindValidatorsInAssembly(Assembly.GetExecutingAssembly())
            .ForEach(match => kernel.Bind(match.InterfaceType).To(match.ValidatorType));
        }
Example #36
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // logging
            kernel.Bind <ILogger>().To <NLogLogger>().InSingletonScope();

            // context
            kernel.Bind <EfDbContext>().To <EfDbContext>().InRequestScope();

            // filters
            kernel.BindFilter <OrganizationAuthorize>(FilterScope.Controller, 0);
            kernel.BindFilter <ConfirmationRequired>(FilterScope.Controller, null);
            kernel.BindFilter <GuestRequired>(FilterScope.Controller, null);
            kernel.BindFilter <LogUserActivityAttribute>(FilterScope.Controller, null);

            // convention based binding
            kernel.Bind(
                x => x.FromAssembliesMatching("Britespokes.Services.dll", "Britespokes.Data.dll", "Britespokes.Web.dll")
                .SelectAllClasses().BindDefaultInterface());

            kernel.Bind(
                x =>
                x.FromAssembliesMatching("Britespokes.Data.dll")
                .SelectAllClasses()
                .InheritedFrom(typeof(IRepository <>))
                .BindAllInterfaces());

            // mailers
            kernel.Bind <OrderNotificationMailerController>().To <OrderNotificationMailerController>()
            .InRequestScope()
            .WithConstructorArgument("orderNotificationEmailAddress", EnvironmentConfig.OrderNotificationEmailAddress);

            kernel.Bind <GiftOrderNotificationMailerController>().To <GiftOrderNotificationMailerController>()
            .InRequestScope()
            .WithConstructorArgument("giftorderNotificationEmailAddress", EnvironmentConfig.GiftOrderNotificationEmailAddress);

            kernel.Bind <StudentInquiryMailerController>().To <StudentInquiryMailerController>()
            .InRequestScope()
            .WithConstructorArgument("studentInquiryNotificationEmailAddress", EnvironmentConfig.StudentInquiryNotificationEmailAddress);

            // services
            kernel.Bind <IAuthenticationService>().To <FormsAuthenticationService>().InRequestScope();

            // uploaders
            kernel.Bind <IImageUploader>().To <AzureImageUploader>().InRequestScope();
        }
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind<IReportsService>().To<ReportsService>();
     kernel.Bind<IReportParametersService>().To<ReportParameterService>();
     kernel.Bind<IRoleService>().To<RoleService>();
     kernel.Bind<IReportParameterFactory>().To<ReportParameterFactory>();
     kernel.Bind<IReportsContext>().To<ReportsContext>().InRequestScope();
     kernel.Bind<IUserContext>().To<UsersContext>().InRequestScope();
     kernel.BindFilter<SetUserLogo>(FilterScope.Controller, 0);
 }
        private static void RegisterFilters(IKernel kernel)
        {
            kernel.BindFilter<AuthorizationFilter>(System.Web.Mvc.FilterScope.Controller, 0)
                .WhenControllerHas<CustomAuthorize>()
                .WithConstructorArgumentFromControllerAttribute<CustomAuthorize>(
                "requiredRight",
                attribute => attribute.RequiredRight)
                .WithConstructorArgumentFromControllerAttribute<CustomAuthorize>(
                "requiredRightOperations",
                attribute => attribute.RequiredRightOperations);

            kernel.BindFilter<AuthorizationFilter>(System.Web.Mvc.FilterScope.Action, 0)
                .WhenActionMethodHas<CustomAuthorize>()
                .WithConstructorArgumentFromActionAttribute<CustomAuthorize>(
                "requiredRight",
                attribute => attribute.RequiredRight)
                .WithConstructorArgumentFromActionAttribute<CustomAuthorize>(
                "requiredRightOperations",
                attribute => attribute.RequiredRightOperations);
        }
Example #39
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter <DebugWamsAuthenticationFilter>(FilterScope.First, 0);


            kernel.BindFilter <CurrentAgencyFilter>(FilterScope.Global, 1);

            kernel.Bind(x => x.FromAssemblyContaining(
                            typeof(BaseController),
                            typeof(BaseBusiness <>),
                            typeof(AgencyBusiness)
                            )
                        .SelectAllClasses()
                        .BindDefaultInterface());

            kernel.Rebind <IEdFiAdminDbContext>().To <EdFiAdminDbContext>().InRequestScope();
            kernel.Rebind <IOdsDbContext>().To <OdsDbContext>().InRequestScope();
            kernel.Rebind <IEdFiSecurityDbContext>().To <EdFiSecurityDbContext>().InRequestScope();
            kernel.Rebind <ISessionInfo>().To <SessionInfo>().InRequestScope();
        }
Example #40
0
        private static void RegisterServices(IKernel kernel)
        {
            //kernel.BindFilter<AuthenticationFilter>(FilterScope.First, 0).InRequestScope();
            kernel.BindFilter <ExceptionFilter>(FilterScope.Global, 1);

            kernel.Bind(x =>
            {
                x.FromThisAssembly()
                .SelectAllClasses()
                .BindDefaultInterface();
            });

            //x.FromAssemblyContaining(
            //    typeof(Business.AgencyBusiness),

            //MediatR
            kernel.Components.Add <IBindingResolver, ContravariantBindingResolver>();
            kernel.Bind(scan =>
                        scan.FromAssemblyContaining <IMediator>()
                        .SelectAllClasses()
                        .BindDefaultInterface());
            //kernel.Bind<TextWriter>().ToConstant(writer);

            kernel.Bind(scan => scan.FromAssemblyContaining <Ping>().SelectAllClasses().InheritedFrom(typeof(IRequestHandler <,>)).BindAllInterfaces());
            kernel.Bind(scan => scan.FromAssemblyContaining <Ping>().SelectAllClasses().InheritedFrom(typeof(IRequestHandler <>)).BindAllInterfaces());
            kernel.Bind(scan => scan.FromAssemblyContaining <Ping>().SelectAllClasses().InheritedFrom(typeof(INotificationHandler <>)).BindAllInterfaces());

            //Pipeline
            kernel.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestPreProcessorBehavior <,>));
            kernel.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestPostProcessorBehavior <,>));
            //kernel.Bind(typeof(IPipelineBehavior<,>)).To(typeof(GenericPipelineBehavior<,>));
            //kernel.Bind(typeof(IRequestPreProcessor<>)).To(typeof(GenericRequestPreProcessor<>));
            //kernel.Bind(typeof(IRequestPostProcessor<,>)).To(typeof(GenericRequestPostProcessor<,>));
            //kernel.Bind(typeof(IRequestPostProcessor<,>)).To(typeof(ConstrainedRequestPostProcessor<,>));
            //kernel.Bind(typeof(INotificationHandler<>)).To(typeof(ConstrainedPingedHandler<>)).WhenNotificationMatchesType<Pinged>();

            kernel.Bind <SingleInstanceFactory>().ToMethod(ctx => t => ctx.Kernel.TryGet(t));
            kernel.Bind <MultiInstanceFactory>().ToMethod(ctx => t =>
            {
                try
                {
                    return(ctx.Kernel.GetAll(t).ToList());
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    return(new object[0]);
                }
            });

            //kernel.Bind<IFilterProvider>().To<NinjectWebApiFilterProvider>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            var modules = new List<NinjectModule>
                              {
                                  new MvcModule()
                              };
            kernel.Load(modules);

            kernel.BindFilter<ErrorLoggingAttribute>(FilterScope.Global, 1);
            //kernel.BindFilter<ValidateN2ShopperProfileAttribute>(FilterScope.Global, 4);

            DependencyResolver.Register(
                kernel.Get<IDependencyResolver>());
        }        
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            var modules = new List <NinjectModule>
            {
                new MvcModule()
            };

            kernel.Load(modules);

            kernel.BindFilter <ErrorLoggingAttribute>(FilterScope.Global, 1);
            //kernel.BindFilter<ValidateN2ShopperProfileAttribute>(FilterScope.Global, 4);

            DependencyResolver.Register(
                kernel.Get <IDependencyResolver>());
        }
Example #43
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            //loading the repository module...
            kernel.Load(new RepositoryModule());

            //var ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
            //ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(ninjectValidatorFactory));
            //DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            //FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);

            AssemblyScanner.FindValidatorsInAssembly(Assembly.GetExecutingAssembly())
            .ForEach(match => kernel.Bind(match.InterfaceType).To(match.ValidatorType));

            //bindings..
            kernel.Bind <ICoreRepository>().To <CoreRepository>();
            kernel.Bind <IAccountRepository>().To <AccountRepository>();
            kernel.Bind <IAdminUnitRepository>().To <AdminUnitRepository>();
            kernel.Bind <IGeneralHelper>().To <GeneralHelper>();
            kernel.Bind <IValidationHelper>().To <ValidationHelper>();
            kernel.Bind <IStudentRepository>().To <StudentRepository>();
            kernel.Bind <IStaffRepository>().To <StaffRepository>();
            kernel.Bind <IAuditRepository>().To <AuditRepository>();
            kernel.Bind <ISemesterRepository>().To <SemesterRepository>();
            kernel.Bind <IAcademicYearRepository>().To <AcademicYearRepository>();
            kernel.Bind <IUserManagementRepository>().To <UserManagementRepository>();
            kernel.Bind <ISemesterRegistrationRepository>().To <SemesterRegistrationRepository>();
            kernel.Bind <IStudentCourseRepository>().To <StudentCourseRepository>();
            kernel.Bind <IOauthRepository>().To <OauthRepository>();
            kernel.Bind <IStaffCourseRepository>().To <StaffCourseRepository>();
            kernel.Bind <IStudentsHelper>().To <StudentsHelper>();
            kernel.Bind <ICourseRepository>().To <CourseRepository>();

            kernel.BindFilter <AuditAttribute>(FilterScope.Action, 0).WhenActionMethodHas <AuditAttribute>().InRequestScope();
            kernel.BindFilter <AuthorizeUserAttribute>(FilterScope.Action, 0)
            .WhenActionMethodHas <AuthorizeUserAttribute>().InRequestScope();
        }
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<AppContext>().ToSelf().InRequestScope();
            kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope();

            kernel.BindFilter<StatusActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<StatusActionAttribute>();
            kernel.BindFilter<RolesActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<RolesActionAttribute>();
            kernel.BindFilter<PlanListActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<PlanListAttribute>();
            kernel.BindFilter<PartnerActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<PartnerAttribute>();
            kernel.BindFilter<HostedOrganisationActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<HostedOrganisationAttribute>();
            kernel.BindFilter<AccountActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<AccountAttribute>();
            kernel.BindFilter<ADUserActionFilter>(System.Web.Mvc.FilterScope.Controller, 0).WhenControllerHas<ADUserActionAttribute>();

            kernel.Bind(x => { x.From(typeof(UserManagerService).Assembly).SelectAllClasses().EndingWith("Service").BindDefaultInterface(); });
            kernel.Bind(typeof (IAdUserService)).To(typeof (AdUserSevice));

            kernel.Bind(typeof(IUserStore<AppIdentityUser>)).To(typeof(UserStore<AppIdentityUser>)).WithConstructorArgument("context", kernel.Get<AppContext>());
            kernel.Bind(typeof(UserManager<AppIdentityUser>)).To(typeof(UserManager<AppIdentityUser>)).WithConstructorArgument("store", kernel.Get<IUserStore<AppIdentityUser>>());

            kernel.Bind(typeof(IRoleStore<IdentityRole, string>)).To(typeof(RoleStore<IdentityRole>)).WithConstructorArgument("context", kernel.Get<AppContext>());
            kernel.Bind(typeof(RoleManager<IdentityRole>)).To(typeof(RoleManager<IdentityRole>)).WithConstructorArgument("store", kernel.Get<IRoleStore<IdentityRole, string>>());

            kernel.Bind<IAuthenticationManager>().ToMethod(c => HttpContext.Current.GetOwinContext().Authentication);
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // logging
              kernel.Bind<ILogger>().To<NLogLogger>().InSingletonScope();

              // context
              kernel.Bind<EfDbContext>().To<EfDbContext>().InRequestScope();

              // filters
              kernel.BindFilter<OrganizationAuthorize>(FilterScope.Controller, 0);
              kernel.BindFilter<ConfirmationRequired>(FilterScope.Controller, null);
              kernel.BindFilter<GuestRequired>(FilterScope.Controller, null);
              kernel.BindFilter<LogUserActivityAttribute>(FilterScope.Controller, null);

              // convention based binding
              kernel.Bind(
            x => x.FromAssembliesMatching("Britespokes.Services.dll", "Britespokes.Data.dll", "Britespokes.Web.dll")
              .SelectAllClasses().BindDefaultInterface());

              kernel.Bind(
            x =>
              x.FromAssembliesMatching("Britespokes.Data.dll")
            .SelectAllClasses()
            .InheritedFrom(typeof (IRepository<>))
            .BindAllInterfaces());

              // mailers
              kernel.Bind<OrderNotificationMailerController>().To<OrderNotificationMailerController>()
            .InRequestScope()
            .WithConstructorArgument("orderNotificationEmailAddress", EnvironmentConfig.OrderNotificationEmailAddress);

              kernel.Bind<GiftOrderNotificationMailerController>().To<GiftOrderNotificationMailerController>()
              .InRequestScope()
              .WithConstructorArgument("giftorderNotificationEmailAddress", EnvironmentConfig.GiftOrderNotificationEmailAddress);

              kernel.Bind<StudentInquiryMailerController>().To<StudentInquiryMailerController>()
            .InRequestScope()
            .WithConstructorArgument("studentInquiryNotificationEmailAddress", EnvironmentConfig.StudentInquiryNotificationEmailAddress);

              // services
              kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>().InRequestScope();

              // uploaders
              kernel.Bind<IImageUploader>().To<AzureImageUploader>().InRequestScope();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.BindFilter<LayoutViewModelInjectorAttribute>(FilterScope.Global, 0);
            kernel.BindFilter<HandleErrorAttribute>(FilterScope.Global, 0);
            kernel.BindFilter<AuthorizeAttribute>(FilterScope.Global, 0);
            kernel.Bind<IPasswordHasher>().To<PasswordHasher>();

            if (ConfigurationManager.AppSettings["Repository"] != null)
            {
                if (ConfigurationManager.AppSettings["Repository"] == "InMemory")
                {
                    RegisterInMemoryRepository(kernel);
                }
                else if (ConfigurationManager.AppSettings["Repository"] == "SqlServerLocalDatabase")
                {
                    RegisterEFRepository(kernel, "SqlServerLocalDb");
                }
                else if (ConfigurationManager.AppSettings["Repository"] == "SqlServerAzure")
                {
                    RegisterEFRepository(kernel, "SqlServerAzure");
                }
                else
                {
                    throw new ApplicationException("Invalid appSetting for Repository. Valid values are SqlServerLocalDatabase and InMemeory.");
                }
            }
            else
            {
                throw new ApplicationException("Unsure of what repository to use. Configure appSettings Repository key with SqlServerLocalDatabase or InMemory.");
            }
        }
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind<EstoqueContext>().ToSelf().InRequestScope();
     kernel.BindFilter<SaveChangesFilter>(System.Web.Mvc.FilterScope.Global, 1);
 }        
Example #48
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<DbContext>().To<VnsfDbContext>();

            //kernel.Bind(typeof(IRepository<>)).To(typeof(Repository<>));

            kernel.Bind<ILog>().ToMethod(context => LogManager.GetLogger(context.Request.Target.Member.DeclaringType));

            kernel.BindFilter<LogFilter>(FilterScope.Action, 0)
                .When((controllerContext, actionDescriptor) =>
                    actionDescriptor.ControllerDescriptor.ControllerType == typeof(OpportunityController) &&
                    actionDescriptor.ActionName == "ActionName");

            kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InSingletonScope();

            kernel.Bind(x => x
                     .FromAssembliesMatching("Vnsf.*.dll")
                     .SelectAllClasses()
                     .Excluding<UnitOfWork>()
                     .BindAllInterfaces());
        }
Example #49
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<ISessionFactory>().To<TenantSessionFactory>();
            kernel.Bind<ISessionDetails>().ToMethod(c =>
            {
                ISessionDetails sessionDetails = null;
                try
                {
                    var sessionFactory = new TenantSessionFactory();
                    sessionDetails = sessionFactory.GetSession();
                }
                catch (Exception)
                {

                }
                return sessionDetails;
            });
            kernel.Bind<ISessionHelper>().To<SessionHelper>();
            kernel.Bind<IHttpContextHelper>().To<HttpContextHelper>();
            kernel.Bind<IEncryptionHelper>().To<EncryptionHelper>();
            kernel.BindFilter<SetSessionDetailViewDataFilter>(FilterScope.Global, null).When(r => true);

            kernel.Bind<ITenantService>().ToMethod(c => ITenantService_Channel.Create());

            kernel.BindFilter<LoginFilter>(System.Web.Mvc.FilterScope.Action, 0).WhenActionMethodHasNo<UnsecuredAttribute>();
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind(typeof(IRepository<,>)).To(typeof(GenericRepository<,>));

            kernel.Bind<IEconomDbContext>().To<EconomDbContext>().InRequestScope();
            kernel.Bind<IItemMasterDbContext>().To<ItemMasterDbContext>().InRequestScope();

            kernel.BindFilter<HomeStorageOwnerAttribute>(System.Web.Mvc.FilterScope.Action, 0)
                .WhenActionMethodHas<HomeStorageOwnerWrapperAttribute>();

            kernel.Bind(k => k
                .From(
                    GlobalConstants.DataServicesAssembly,
                    GlobalConstants.SearchersServicesAssembly,
                    GlobalConstants.LogicServicesAssembly,
                    GlobalConstants.ProvidersServicesAssembly)
               .SelectAllClasses()
               .BindDefaultInterface());

            //       kernel.Bind<IStockTicker>()
            //.To<Microsoft.AspNet.SignalR.StockTicker.StockTicker>()  // Bind to StockTicker.
            //.InSingletonScope();  // Make it a singleton object.

            //       kernel.Bind<IHubConnectionContext>().ToMethod(context =>
            //           resolver.Resolve<IConnectionManager>().GetHubContext<StockTickerHub>().Clients
            //           ).WhenInjectedInto<IStockTicker>();
        }
 public static void Bind(IKernel kernel)
 {
     kernel
         .BindFilter<TrackActivityFilter>(FilterScope.Controller, null)
         .WhenControllerHas(typeof(TrackActivityAttribute));
 }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<ILog>().To<SqlLog>();
            kernel.Bind<IContextProvider>().To<GenericContextProvider>().InRequestScope();
            kernel.Bind<IMakeViewModelMapper>().To<MakeViewModelMapper>();
            kernel.Bind<IGetPendingForVehicleViewModelMapper>().To<GetPendingForVehicleViewModelMapper>();
            kernel.Bind<IUserProvider>().To<UserProvider>();
            kernel.Bind<IIndexViewModelMapper>().To<IndexViewModelMapper>();
            kernel.Bind<ICustomerServiceProxy>().To<FakeCustomerServiceProxy>();
            kernel.Bind<IVehicleServiceProxy>().To<VehicleServiceProxy>();
            kernel.BindFilter<EntityFrameworkWriteContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas<EntityFrameworkWriteContextAttribute>();
            kernel.BindFilter<EntityFrameworkReadContextFilter>(FilterScope.Action, 1000).WhenActionMethodHas<EntityFrameworkReadContextAttribute>();
            kernel.BindFilter<LogFilter>(FilterScope.Action, 1050).WhenActionMethodHas<LogAttribute>();

            new DataRegistry().RegisterServices(kernel);
        }