A loadable unit that defines bindings for your application.
Inheritance: 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;
 }
        public static MortgageModellingService GetModellingService(NinjectModule bindings)
        {
            IKernel kernel = new StandardKernel(bindings);

              return kernel.Get < MortgageModellingService>();
        }
 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)
 {
 }
 /// <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();
 }