private static void SetupConfiguration(ISessionStateCache stateCache) { var environment = stateCache.GetEnvironment(); var envConf = ConfigurationManager.Instance.GetConfiguration(environment); envConf.GetConnection(); }
private static void InitializeDatabase(ISessionStateCache stateCache) { // Will cache the connection if in memory database SetupConfiguration(stateCache); // If database config is in memory, connection will be cached in in session state var conn = GetConnectionFromSessionState((IConnectionCache)stateCache); if (conn == null) return; // Connection has been cache so in memory database SetupInMemoryDatabase(stateCache, conn); }
private static void SetupInMemoryDatabase(ISessionStateCache stateCache, IDbConnection conn) { var fact = SessionFactoryManager.GetSessionFactory(stateCache.GetEnvironment()); stateCache.SetSessionFactory(fact); UseSessionFactoryFromApplicationOrSessionCache(stateCache); var session = ObjectFactory.GetInstance<ISessionFactory>().OpenSession(conn); SessionFactoryManager.BuildSchema(stateCache.GetEnvironment(), session); CurrentSessionContext.Bind(session); UserServices.ConfigureSystemUser(); }
private static void SetupInMemoryDatabase(ISessionStateCache stateCache, IDbConnection conn) { var fact = SessionFactoryManager.GetSessionFactory(stateCache.GetEnvironment()); stateCache.SetSessionFactory(fact); UseSessionFactoryFromApplicationOrSessionCache(stateCache); var session = ObjectFactory.GetInstance <ISessionFactory>().OpenSession(conn); SessionFactoryManager.BuildSchema(stateCache.GetEnvironment(), session); CurrentSessionContext.Bind(session); UserServices.ConfigureSystemUser(); }
private static void UseSessionFactoryFromApplicationOrSessionCache(ISessionStateCache stateCache) { if (IsEmptyCache(stateCache)) { ObjectFactory.Configure( x => x.For <ISessionFactory>().Use(GenFormApplication.GetSessionFactory(stateCache.GetEnvironment()))); } else { ObjectFactory.Configure( x => x.For <ISessionFactory>().Use(stateCache.GetSessionFactory)); } }
private static void InitializeDatabase(ISessionStateCache stateCache) { // Will cache the connection if in memory database SetupConfiguration(stateCache); // If database config is in memory, connection will be cached in in session state var conn = GetConnectionFromSessionState((IConnectionCache)stateCache); if (conn == null) { return; } // Connection has been cache so in memory database SetupInMemoryDatabase(stateCache, conn); }
public void Init() { _sessionState = Isolate.Fake.Instance <HttpSessionStateBase>(); _factory = Isolate.Fake.Instance <ISessionFactory>(); Isolate.WhenCalled(() => _sessionState[HttpSessionStateCache.SessionFactorySetting]).WillReturn(_factory); _stateCache = new HttpSessionStateCache(_sessionState); ObjectFactory.Configure(x => x.For <ISessionStateCache>().Use(_stateCache)); Isolate.Fake.StaticMethods(typeof(UserServices)); // ReSharper disable UnusedVariable, otherwise ConfigurationManager will not be faked var confMan = ConfigurationManager.Instance; // ReSharper restore UnusedVariable Isolate.Fake.StaticMethods <ConfigurationManager>(); ObjectFactory.Configure(x => x.For <IDatabaseServices>().Use <DatabaseServices>()); _services = ObjectFactory.GetInstance <IDatabaseServices>(); _services.SessionStateCache = _stateCache; }
private static void UseSessionFactoryFromApplicationOrSessionCache(ISessionStateCache stateCache) { if (IsEmptyCache(stateCache)) ObjectFactory.Configure( x => x.For<ISessionFactory>().Use(GenFormApplication.GetSessionFactory(stateCache.GetEnvironment()))); else { ObjectFactory.Configure( x => x.For<ISessionFactory>().Use(stateCache.GetSessionFactory)); } }
private static bool IsEmptyCache(ISessionStateCache stateCache) { return stateCache is EmptySessionStateCache; }
public void Init() { _sessionState = Isolate.Fake.Instance<HttpSessionStateBase>(); _factory = Isolate.Fake.Instance<ISessionFactory>(); Isolate.WhenCalled(() => _sessionState[HttpSessionStateCache.SessionFactorySetting]).WillReturn(_factory); _stateCache = new HttpSessionStateCache(_sessionState); ObjectFactory.Configure(x => x.For<ISessionStateCache>().Use(_stateCache)); Isolate.Fake.StaticMethods(typeof(UserServices)); // ReSharper disable UnusedVariable, otherwise ConfigurationManager will not be faked var confMan = ConfigurationManager.Instance; // ReSharper restore UnusedVariable Isolate.Fake.StaticMethods<ConfigurationManager>(); ObjectFactory.Configure(x => x.For<IDatabaseServices>().Use<DatabaseServices>()); _services = ObjectFactory.GetInstance<IDatabaseServices>(); _services.SessionStateCache = _stateCache; }
private static bool IsEmptyCache(ISessionStateCache stateCache) { return(stateCache is EmptySessionStateCache); }