Exemplo n.º 1
0
 /// <summary>
 /// Called if an action on the session fails
 /// </summary>
 /// <param name="session"></param>
 public void FailSession(ISession session)
 {
     if (threadScopeInfo.HasInitializedScope)
     {
         ISessionScope scope = threadScopeInfo.GetRegisteredScope();
         scope.FailSession(session);
     }
     else
     {
         session.Clear();
     }
 }
Exemplo n.º 2
0
        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 = null;

                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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the registered scope.
 /// </summary>
 /// <returns></returns>
 public ISessionScope GetRegisteredScope()
 {
     if (scopeInfo == null)
     {
         throw new ActiveRecordException(
                   "Can't get registered scope because the Active Record framework was not initialized.");
     }
     return(scopeInfo.GetRegisteredScope());
 }
Exemplo n.º 4
0
 public ISessionScope GetRegisteredScope()
 {
     return(scopeInfo.GetRegisteredScope());
 }