public static void ConfigureDataAccess(IPersistenceConfigurer databaseConfigurer, InstanceScope sessionScope, out NHibernate.Cfg.Configuration cfg)
 {
     NHibernate.Cfg.Configuration configuration = null;
     ObjectFactory.Initialize(i => ConfigureDataAccess(i, databaseConfigurer, sessionScope, out configuration));
     ObjectFactory.AssertConfigurationIsValid();
     cfg = configuration;
 }
 public static void ConfigureDataAccess(IInitializationExpression i, string sqlServerAddress, string username,
     string password, string database, InstanceScope sessionScope)
 {
     NHibernate.Cfg.Configuration cfg;
     ConfigureDataAccess(i, MsSqlConfiguration.MsSql2005.ConnectionString(c =>
         c.Server(sqlServerAddress).Username(username).Password(password).Database(database)),sessionScope, out cfg);
 }
        private void RegisterInitialOrConfigure(Type serviceType, InstanceScope scope, Action<GenericFamilyExpression> use)
        {
            var registry = this.initialRegistry ?? new Registry();
            use(registry.For(serviceType).LifecycleIs(scope));

            if (this.container != null)
                this.container.Configure(c => c.AddRegistry(registry));
        }
        public static void ConfigureDataAccess(IInitializationExpression i, IPersistenceConfigurer databaseConfigurer, InstanceScope sessionScope, out NHibernate.Cfg.Configuration cfg)
        {
            cfg = new NHibernate.Cfg.Configuration();

            i.ForRequestedType<ISessionFactory>()
                .CacheBy(InstanceScope.Singleton)
                .TheDefault.IsThis(ConfigureNHibernate(databaseConfigurer, cfg));

            i.ForRequestedType<ISession>()
                .CacheBy(sessionScope)
                .TheDefault.Is.ConstructedBy(() =>
                                             ObjectFactory.GetInstance<ISessionFactory>
                                                 ().OpenSession());

            //More StructureMap configuration goes here:

            //i.ForRequestedType<ISomeModelRepository>()
            //    .CacheBy(InstanceScope.PerRequest)
            //    .TheDefaultIsConcreteType<SomeModelRepository>();
        }
 public static void ConfigureDataAccess(string sqlServerAddress, string username,
     string password, string database, InstanceScope sessionScope)
 {
     ObjectFactory.Initialize(i => ConfigureDataAccess(i, sqlServerAddress, username, password, database, sessionScope));
     ObjectFactory.AssertConfigurationIsValid();
 }