private ISession CreateScopeSession(Type type) { ISessionScope scope = threadScopeInfo.GetRegisteredScope(); ISessionFactory sessionFactory = GetSessionFactory(type); #if DEBUG System.Diagnostics.Debug.Assert(scope != null); System.Diagnostics.Debug.Assert(sessionFactory != null); #endif if (scope.IsKeyKnown(sessionFactory)) { return(scope.GetSession(sessionFactory)); } else { ISession session; if (scope.WantsToCreateTheSession) { session = OpenSessionWithScope(scope, sessionFactory); } else { session = OpenSession(sessionFactory); } #if DEBUG System.Diagnostics.Debug.Assert(session != null); #endif scope.RegisterSession(sessionFactory, session); return(session); } }