protected override void Init() { ComponentRegistration <object> component = Component.For(typeof(IRepository <>)).ImplementedBy(typeof(NHRepository <>)); if (!string.IsNullOrEmpty(config.RepositoryKey)) { component.Named(config.RepositoryKey); } Kernel.Register(component); ComponentRegistration <IUnitOfWorkFactory> registerFactory = Component.For <IUnitOfWorkFactory>() .ImplementedBy <NHibernateUnitOfWorkFactory>(); registerFactory.Parameters(ComponentParameter.ForKey("configurationFileName").Eq(config.NHibernateConfigurationFile)); // if we are running in test mode, we don't want to register // the assemblies directly, we let the DatabaseTestFixtureBase do it // this allow us to share the configuration between the test & prod projects if (DatabaseTestFixtureBase.IsRunningInTestMode == false) { registerFactory.DependsOn(Property.ForKey("assemblies").Eq(Assemblies)); } Kernel.Register(registerFactory); Kernel.AddComponentInstance("entitiesToRepositories", typeof(INHibernateInitializationAware), new EntitiesToRepositoriesInitializationAware(config.IsCandidateForRepository)); }