Esempio n. 1
0
        public void OpenSession()
        {
            ISession session = GetNewSession();
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(session);
        }
Esempio n. 2
0
        public void Close()
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            currentSession.Close();
        }
Esempio n. 3
0
        public static ISessionStorageContainer GetStorageContainer()
        {
            if (sessionStorageContainer == null)
            {
                sessionStorageContainer = new HttpSessionContainer();
            }

            return sessionStorageContainer;
        }        
Esempio n. 4
0
        public static ISessionStorageContainer GetStorageContainer()
        {
            if (NhSessionStorageContainer == null)
            {
                if (HttpContext.Current != null)
                    NhSessionStorageContainer = new HttpSessionContainer();
            }

            return NhSessionStorageContainer;
        }
		public static ISessionStorageContainer GetStorageContainer()
		{
			if (_nhSessionStorageContainer == null)
			{
				if (HttpContext.Current == null)
					_nhSessionStorageContainer = new ThreadSessionStorageContainer();
				else
					_nhSessionStorageContainer = new HttpSessionContainer();
			}
			return _nhSessionStorageContainer;
		}
 public static ISessionStorageContainer <IT> GetStorageContainer()
 {
     if (_nhSessionStorageContainer == null)
     {
         if (HttpContext.Current != null)
         {
             _nhSessionStorageContainer = new HttpSessionContainer <IT>(_sessionKey);
         }
     }
     return(_nhSessionStorageContainer);
 }
Esempio n. 7
0
        public ISession GetCurrentSession()
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }
            return(currentSession);
        }
        public static ISessionStorageContainer GetStorageContainer()
        {
            if (_nhSessionStorageContainer == null)
            {
                //if (HttpContext.Current == null)
                //    _nhSessionStorageContainer = new ThreadSessionStorageContainer();
                //else
                _nhSessionStorageContainer = new HttpSessionStorageContainer();
            }

            return(_nhSessionStorageContainer);
        }
        public void CloseSession()
        {
            ISession session = GetCurrentSession();

            if (session != null && session.IsOpen)
            {
                //session.Flush();
                session.Close();
            }
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(null);
        }
Esempio n. 10
0
        public static ISession GetCurrentSession(string dbName)
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            ISession currentSession = sessionStorageContainer.GetCurrentSession(dbName);

            if (currentSession == null)
            {
                currentSession = GetNewSession(dbName);
                sessionStorageContainer.Store(dbName, currentSession);
            }

            return(currentSession);
        }
 public static ISessionStorageContainer GetStorageContainer()
 {
     if (_sessionStorageContainer == null)
     {
         if (HttpContext.Current == null)
         {
             _sessionStorageContainer = new ThreadSessionStorageContainer();
         }
         else
         {
             _sessionStorageContainer = new HttpSessionContainer();
         }
     }
     return(_sessionStorageContainer);
 }
        public static ISession GetCurrentSession(Web.IHttpContextAccessor context)
        {
            ISessionStorageContainer sessionStorageContainer =
                SessionStorageFactory.GetStorageContainer(context);

            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }

            return(currentSession);
        }
        public static ISessionStorageContainer GetStorageContainer(IHttpContextAccessor context)
        {
            if (_nhSessionStorageContainer == null)
            {
                if (context.HttpContext == null)
                {
                    _nhSessionStorageContainer = new ThreadSessionStorageContainer();
                }
                else
                {
                    _nhSessionStorageContainer = new HttpSessionContainer(context);
                }
            }

            return(_nhSessionStorageContainer);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
    public static ISessionStorageContainer GetStorageContainer(string key)
    {
        ISessionStorageContainer storageContainer = _nhSessionStorageContainer.ContainsKey(key) ? _nhSessionStorageContainer[key] : null;

        if (storageContainer == null)
        {
            if (HttpContext.Current == null)
            {
                storageContainer = new ThreadSessionStorageContainer(key);
                _nhSessionStorageContainer.Add(key, storageContainer);
            }
            else
            {
                storageContainer = new HttpSessionContainer(key);
                _nhSessionStorageContainer.Add(key, storageContainer);
            }
        }
        return(storageContainer);
    }
 public static ISessionStorageContainer GetStorageContainer()
 {
     _nhSessionStorageContainer = new ThreadSessionContainer();
     return _nhSessionStorageContainer;
 }
Esempio n. 17
0
 public SessionFactory(IConfigurationBuilder configurationBuilder, ISessionStorageContainer sessionStorageContainer)
 {
     _configurationBuilder    = configurationBuilder;
     _sessionStorageContainer = sessionStorageContainer;
 }
Esempio n. 18
0
 public SessionFactory(IConfigurationBuilder configurationBuilder, ISessionStorageContainer sessionStorageContainer)
 {
     _configurationBuilder = configurationBuilder;
     _sessionStorageContainer = sessionStorageContainer;
 }
Esempio n. 19
0
 public static ISessionStorageContainer GetStorageContainer()
 {
     _nhSessionStorageContainer = new ThreadSessionContainer();
     return(_nhSessionStorageContainer);
 }
 public SessionStorageFactory(ISessionStorageContainer nhSessionStorageContainer)
 {
     _nhSessionStorageContainer = nhSessionStorageContainer;
 }
 public SessionStorageFactory(ISessionStorageContainer nhSessionStorageContainer)
 {
     _nhSessionStorageContainer = nhSessionStorageContainer;
 }