示例#1
0
 private static void ConfigureMediator(KernelBase kernel)
 {
     kernel.Components.Add <IBindingResolver, ContravariantBindingResolver>();
     kernel.Bind <SingleInstanceFactory>().ToMethod(ctx => t => ctx.Kernel.Get(t));
     kernel.Bind <MultiInstanceFactory>().ToMethod(ctx => t => ctx.Kernel.GetAll(t));
     kernel.Bind <IMediator>().To <Mediator>();
 }
示例#2
0
        public void Register <TInterface, TImplementation>(LifeCycle lf = LifeCycle.PerApplication) where TImplementation : TInterface
        {
            kernel.Unbind <TInterface>();
            var bindConfig = kernel.Bind <TInterface>().To <TImplementation>();

            if (lf == LifeCycle.PerRequest)
            {
                bindConfig.InRequestScope();
            }
        }
示例#3
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IMedicoRepository>().To <MedicoRepository>();
     kernel.Bind <IFactory <MenuVoice, Model.MenuVoice> >().To <MenuFactory>();
     kernel.Bind <IFactory <Answer, Model.Answer> >().To <AnswerFactory>();
     kernel.Bind <IFactory <AnswerComment, Model.AnswerComment> >().To <AnswerCommentFactory>();
     kernel.Bind <IFactory <Question, Model.Question> >().To <QuestionFactory>();
     kernel.Bind <IFactory <QuestionComment, Model.QuestionComment> >().To <QuestionCommentFactory>();
     kernel.Bind <IFactory <Tag, Model.Tag> >().To <TagFactory>();
     kernel.Bind <IFactory <User, Model.User> >().To <UserFactory>();
     kernel.Bind <IFactory <Profile, Model.Profile> >().To <ProfileFactory>();
 }
示例#4
0
        public static void BindMock <TMock>(this KernelBase kernel, Action <Mock <TMock> > mockSetup) where TMock : class
        {
            var mock = new Mock <TMock>();

            mockSetup(mock);
            kernel.Bind <TMock>().ToConstant(mock.Object);
        }
示例#5
0
        public static void Setup(IServiceCollection serviceCollection)
        {
            KernelBase kernel = ((NinjectServiceCollection)serviceCollection).Kernel;

            kernel.Components.Add <IBindingResolver, ContravariantBindingResolver>();

            kernel.Bind(x => x.FromAssemblyContaining <IMediator>().SelectAllClasses().BindDefaultInterface());
            kernel.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequest>().SelectAllClasses().InheritedFrom(typeof(IRequestHandler <,>)).BindAllInterfaces());
            kernel.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequestValidator>().SelectAllClasses().InheritedFrom(typeof(AbstractValidator <>)).BindDefaultInterfaces());

            kernel
            .Bind(typeof(IPipelineBehavior <,>))
            .To(typeof(RequestPerformanceBehavior <,>));

            kernel
            .Bind(typeof(IPipelineBehavior <,>))
            .To(typeof(RequestValidationBehavior <,>));

            kernel
            .Bind <ServiceFactory>()
            .ToMethod(x =>
            {
                return(type => x.Kernel.TryGet(type));
            });
        }
示例#6
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <ApplicationDbContext>().ToSelf();
     kernel.Bind <ApplicationUserManager>().ToMethod(ctx => HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>()).InRequestScope();
     kernel.Bind <ApplicationRoleManager>().ToMethod(ctx => HttpContext.Current.GetOwinContext().GetUserManager <ApplicationRoleManager>()).InRequestScope();
     kernel.Bind <IHttpControllerActivator>().To <ContextCapturingControllerActivator>().InRequestScope();
     kernel.Bind <IAuthRepository>().To <AuthRepository>();
     kernel.Bind <IAuthHelper>().To <AuthHelper>();
 }
示例#7
0
 private static void RegisterServices(KernelBase kernel)
 {
     //kernel.Bind<SimpleAuthorizationServerProvider>().To<SimpleAuthorizationServerProvider>();
     kernel.Bind <IGroupService>().To <GroupService>();
     kernel.Bind <IAuthService>().To <AuthService>();
     kernel.Bind <IUserService>().To <UserService>();
     kernel.Bind <IInfoService>().To <InfoService>();
     kernel.Bind <IClientService>().To <ClientService>();
     kernel.Bind <ISaleService>().To <SaleService>();
 }
示例#8
0
        public static void RegisterServices(KernelBase kernel)
        {
            // Services
            kernel.Bind <IOccupationRatingsService>().To <OccupationRatingsService>();
            kernel.Bind <IOccupationsService>().To <OccupationsService>();
            kernel.Bind <IMembersService>().To <MembersService>();

            // Repositories
            kernel.Bind <IOccupationRatingsRepository>().To <OccupationRatingsRepository>();
            kernel.Bind <IOccupationsRepository>().To <OccupationsRepository>();
            kernel.Bind <IMembersRepository>().To <MembersRepository>();

            // Libraries
            kernel.Bind <ILogger>().To <NLogger>();
        }
        public static IMediator Setup(KernelBase dependencyContainer)
        {
            dependencyContainer.Components.Add <IBindingResolver, ContravariantBindingResolver>();
            dependencyContainer.Bind(x => x.FromAssemblyContaining <IMediator>().SelectAllClasses().BindDefaultInterface());
            dependencyContainer.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequest>().SelectAllClasses().InheritedFrom(typeof(IRequestHandler <,>)).BindAllInterfaces());
            dependencyContainer.Bind(x => x.FromAssemblyContaining <CreateSnapshotRequestValidator>().SelectAllClasses().InheritedFrom(typeof(AbstractValidator <>)).BindDefaultInterfaces());

            dependencyContainer.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestPerformanceBehavior <,>));
            dependencyContainer.Bind(typeof(IPipelineBehavior <,>)).To(typeof(RequestValidationBehavior <,>));

            dependencyContainer.Bind <ServiceFactory>().ToMethod(x => t => x.Kernel.TryGet(t));

            return(dependencyContainer.Get <IMediator>());
        }
示例#10
0
        private static void RegisterAssemblies(KernelBase kernel)
        {
            List <string> listAssembly = new List <string>()
            {
                "Website.Foundation.*",
                "Website.WebApi.*"
            };
            List <string> listExcludeAssembly = new List <string>()
            {
                "Website.Foundation.Persistence.Repositories"
            };

            kernel.Bind(x =>
            {
                x.FromAssembliesMatching(listAssembly) // Scans all assemblies
                .SelectAllClasses()                    // Retrieve all non-abstract classes
                .NotInNamespaces(listExcludeAssembly)
                .BindDefaultInterface();               // Binds the default interface to them;
            });
        }
示例#11
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IStudentSystemData>().To <StudentsSystemData>();
 }
示例#12
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IMusicSystemData>().To <MusicSystemData>();
 }
示例#13
0
        private static void RegisterServices(KernelBase kernel)
        {
            // TODO - put in registrations here...


            kernel.Bind <ILikkleApiLogger>().To <LikkleApiLogger>().InSingletonScope();

            kernel.Bind <ILikkleDbContext>().To <LikkleDbContext>();
            kernel.Bind <ILikkleUoW>().To <LikkleUoW>();

            kernel.Bind <IAreaService>().To <AreaService>();
            kernel.Bind <IGroupService>().To <GroupService>();
            kernel.Bind <IUserService>().To <UserService>();
            kernel.Bind <ISubscriptionService>().To <SubscriptionService>();
            kernel.Bind <IAccelometerAlgorithmHelperService>().To <AccelometerAlgorithmHelperService>();
            kernel.Bind <ISubscriptionSettingsService>().To <SubscriptionSettingsService>();

            kernel.Bind <IConfigurationWrapper>().To <ConfigurationWrapper>();
            kernel.Bind <IGeoCodingManager>().To <GeoCodingManager>();
            kernel.Bind <IPhoneValidationManager>().To <PhoneValidationManager>();

            var mapperConfiguration = new MapperConfiguration(cfg => {
                cfg.AddProfile <EntitiesMappingProfile>();
            });

            kernel.Bind <IConfigurationProvider>().ToConstant(mapperConfiguration);
        }
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IProjectRepository>().To <ProjectRepository>();
 }
示例#15
0
        /// <summary>
        /// The register services.
        /// </summary>
        /// <param name="kernel">
        /// The kernel.
        /// </param>
        private static void RegisterServices(KernelBase kernel)
        {
            //kernel.Bind<IFakeService>()
            //    .To<FakeService>();
            kernel.Bind <BankingDbContext>().ToSelf().InRequestScope();

            kernel.Bind <IBankController>().To <BankController>();
            kernel.Bind <IBankService>().To <BankService>();
            kernel.Bind <IBankRepository>().To <BankRepository>().InRequestScope();

            kernel.Bind <ICurrencyController>().To <CurrencyController>();
            kernel.Bind <ICurrencyService>().To <CurrencyService>();
            kernel.Bind <ICurrencyRepository>().To <CurrencyRepository>().InRequestScope();

            kernel.Bind <IHumanController>().To <HumanController>();
            kernel.Bind <IHumanService>().To <HumanService>();
            kernel.Bind <IHumanRepository>().To <HumanRepository>().InRequestScope();

            kernel.Bind <IAccountController>().To <AccountController>();
            kernel.Bind <IAccountService>().To <AccountService>();
            kernel.Bind <IAccountRepository>().To <AccountRepository>().InRequestScope();

            kernel.Bind <IPlasticController>().To <PlasticController>();
            kernel.Bind <IPlasticService>().To <PlasticService>();
            kernel.Bind <IPlasticRepository>().To <PlasticRepository>().InRequestScope();

            kernel.Bind <IParameterizationsController>().To <ParameterizationsController>();
            kernel.Bind <IParameterizationsService>().To <ParameterizationsService>();
            kernel.Bind <IParameterizationsRepository>().To <ParameterizationsRepository>().InRequestScope();

            kernel.Bind <ICacheProvider>().To <CacheProvider>().InSingletonScope();
        }
示例#16
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind(typeof(IRepository <>)).To(typeof(EfRepository <>));
     kernel.Bind <IMappingService>().To <MappingService>();
     kernel.Bind <IEventsSystemData>().To <EventsSystemData>().InRequestScope();
 }
 public IContainerBuilder RegisterSingleton <T>(T instance) where T : class
 {
     _kernel.Bind <T>().ToConstant(instance);
     return(this);
 }
示例#18
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IAuthRepository>().To <AuthRepository>();
     kernel.Bind <ICrudRepository <UserModel> >().To <ClientRepositoriy>();
 }
示例#19
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IdentityDbContext <User, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim> >().To <Just_DIYDbContext>();
     kernel.Bind <IJustDIYData>().To <JustDIYData>();
 }
示例#20
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IUserService>().To <UserService>();
     kernel.Bind <IWorkerService>().To <WorkerService>();
     kernel.Bind <IReservationService>().To <ReservationService>();
 }
示例#21
0
 private void RegisterServices(KernelBase kernel)
 {
     // TODO - put in registrations here...
     kernel.Bind <IDictionaryService <DictionaryResult> >().To(typeof(OxfordService));
 }
示例#22
0
 private static void RegisterServices(KernelBase kernel)
 {
     kernel.Bind <IOAuthAuthorizationServerOptions>().To <MyOAuthAuthorizationServerOptions>();
     kernel.Bind <IOAuthAuthorizationServerProvider>().To <SimpleAuthorizationServerProvider>();
     kernel.Bind <IUnitOfWork>().To <EfUnitOfWork>();
     kernel.Bind <ICreativeService>().To <CreativeService>();
     kernel.Bind <IMedalService>().To <MedalService>();
     kernel.Bind <ITagsService>().To <TagsService>();
     kernel.Bind <IAccountService>().To <AccountService>();
     kernel.Bind <ICommentsService>().To <CommentsService>();
     kernel.Bind <IChaptersService>().To <ChapterService>();
     kernel.Bind <ILikesService>().To <LikesService>();
     kernel.Bind <IRatingService>().To <RatingService>();
     kernel.Bind <ICategoriesService>().To <CategoriesService>();
     kernel.Bind <IAdminService>().To <AdminService>();
 }
        private static void RegisterServices(KernelBase kernel)
        {
            // TODO - put in registrations here...

            kernel.Bind <IFakeService>().To <FakeService>();
        }