public static ISession GetCurrentSession()
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }
            return(currentSession);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取当前的会话
        /// </summary>
        /// <returns></returns>
        public static ISession GetCurrentSession()
        {
            //获取贮藏容器
            ISessionStorageContainer _sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            //每个实现的贮藏容器获得当前的
            ISession currentSession = _sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                //获取当前贮藏中的会话(需打开OpenSession)
                currentSession = GetNewSession();
                //贮藏容器执行存储当前会话的操作
                _sessionStorageContainer.Store(currentSession);
            }

            return(currentSession);
        }