A loadable unit that defines bindings for your application.
Наследование: BindingRoot, INinjectModule
Пример #1
1
        protected override IKernel CreateKernel()
        {
            var kernel = new StandardKernel();
            NinjectModule[] modules = new NinjectModule[]
            {
                new WebModule()
            };

            kernel.Load(Assembly.GetExecutingAssembly());
            kernel.Load(modules);
            return kernel;
        }
Пример #2
0
 /// <summary>
 /// Creates the kernel that will manage your application.
 /// </summary>
 /// <returns>The created kernel.</returns>
 protected override Ninject.IKernel CreateKernel()
 {
     INinjectModule[] modules = new NinjectModule[]
                             {
                                 new __NAME__Module()
                             };
     return new StandardKernel(modules);
 }
        public ApplicationController(NinjectModule viewModule, NinjectModule coreModule)
            : base(viewModule, coreModule)
        {
            Kernel.Bind<ApplicationControllerBase>().ToConstant<ApplicationController>(this);

            this.MainWindow = new FormCSMMain(this);
            this.WindowPresenter.ShowHomeLayout();
        }
Пример #4
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            NinjectModule[] modules = new NinjectModule[]
            {
                new WebModule(),
            };

            kernel.Load(modules);
        }
Пример #5
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var modules = new NinjectModule[] { new TestBindModule() };
            var kernel = new StandardKernel(modules);

            RegisterServices(kernel);

            return kernel;
        }
Пример #6
0
        protected override IKernel CreateKernel()
        {
            var modules = new NinjectModule[] { new MembershipModule(), new ServiceModule() };
            var kernel = new StandardKernel(modules);
            kernel.Load(Assembly.GetExecutingAssembly());

            GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);

            return kernel;
        }
Пример #7
0
 public static void LoadModules(IKernel kernel)
 {
     var modules = new NinjectModule[]
     {
         new DatabaseModule(),
         new CacheModule(),
         new ServiceModule(),
         new RepositoryModule()
     };
     kernel.Load(modules);
 }
Пример #8
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var modules = new NinjectModule[]
                          {
                              new TaskRegisterModule(),
                              new MetadataProviderModule(),
                              new MvcDIModule()
                          };
            var kernel = new StandardKernel(modules);
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
            kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

            //Support WebAPI
            GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel);

            RegisterServices(kernel);
            return kernel;
        }
Пример #9
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var modules = new NinjectModule[] {new BLLNinjectModule()};
            var kernel = new StandardKernel(modules);
            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return kernel;
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
Пример #10
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // You can swap out modules for different implementations
            // because it is designed with an abstraction layer

            var modules = new NinjectModule[]
                {
                    new FluentValidatorModule(),
                    new EntityFrameworkModule(),
                    // new NHibernateModule(), needs more work done
                };

            kernel.Load(modules); // These modules define the interfaces to be injected
            // Ninject will handle the object lifetime
            // This means it will create new or inject current instances from its container into
            // anything that consumes a defined interface and annotated with [Inject]

            // https://github.com/ninject/ninject.web.mvc.fluentvalidation

            // FluentValidation plugin goes well
            NinjectValidatorFactory ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
            ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(ninjectValidatorFactory));
            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
        }
Пример #11
0
 public override void Load(NinjectModule module)
 {
     module.Bind<Samurai>().ToSelf();
 }
 public void LoadBindings(NinjectModule module)
 {
     
 }
 public ServiceLocatorBindings(NinjectModule module)
 {
     _module = module;
 }
Пример #14
0
        public static MortgageModellingService GetModellingService(NinjectModule bindings)
        {
            IKernel kernel = new StandardKernel(bindings);

              return kernel.Get < MortgageModellingService>();
        }
Пример #15
0
 public void LoadBindings(NinjectModule module)
 {
     module.Bind<ISplashLogic>().To<SplashLogic>().InSingletonScope();
 }
 public void LoadBindings(NinjectModule module)
 {
     module.Bind<IMetaDataLogic>().To<MetaDataLogic>().InSingletonScope();
     module.Bind<IMetaDataScriptedFragment>().To<MetaDataScriptedFragment>().InSingletonScope();
 }
Пример #17
0
 public abstract void Load(NinjectModule module);
 public void LoadBindings(NinjectModule module)
 {
     module.Rebind<ILastReadPostDataProvider>().To<LastReadPostDataProvider>().InSingletonScope();
     module.Rebind<ILastReadPostLogic>().To<LastReadPost>().InSingletonScope();
     module.Rebind<ILastReadPostScriptedFragment>().To<LastReadPostScriptedFragment>().InSingletonScope(); 
 }
Пример #19
0
 internal Startup(NinjectModule module)
 {
     m_Module = module;
 }
Пример #20
0
 public override void Load(NinjectModule module)
 {
     module.Bind<IWeapon>().To<Sword>();
 }
 public ServiceLocatorBindings(NinjectModule registrationModule)
 {
     _registrationModule = registrationModule;
 }
 public void LoadBindings(NinjectModule module)
 {
     module.Bind<IEmoticonLogic>().To<EmoticonLogic>().InSingletonScope();
 }
Пример #23
0
 public override void Load(NinjectModule module)
 {
     LoadExecuted = true;
 }
Пример #24
0
 public override void Load(NinjectModule module)
 {
     module.Bind<IWeapon>().To<BareHands>();
 }
Пример #25
0
 public ApplicationKernel(NinjectModule module)
 {
     Kernel = new StandardKernel(module);
 }
Пример #26
0
 public override void Load(NinjectModule module)
 {
 }
Пример #27
0
 /// <summary>
 /// Add a new module.
 /// </summary>
 /// <param name="ninjectModule">
 /// The module.
 /// </param>
 public void AddModule(NinjectModule ninjectModule)
 {
     this.modules.Add(ninjectModule);
 }
Пример #28
0
        /// <summary>
        /// Unregisters the provided module from the dependency loader.
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        public DependancyBinder UnregisterModule(NinjectModule module)
        {
            if (this.Modules.Contains(module))
            {
                this.Modules.Remove(module);
            }

            return this;
        }
 public void LoadBindings(NinjectModule module)
 {
     module.Bind<IUserHealth>().To<UserHealth>();
 }
 public void LoadBindings(NinjectModule module)
 {
     module.Rebind<IContentLogic>().To<ContentLogic>().InSingletonScope();
 }