public ISession CurrentSession()
        {
            ISession currentSession = GetExistingSession(ReflectiveHttpContext.HttpContextCurrentGetter(), factory);

            if (currentSession == null)
            {
                throw new HibernateException("No session bound to the current HttpContext");
            }
            return(currentSession);
        }
        private static IDictionary GetSessionMap(object httpContext, bool create)
        {
            IDictionary httpContextItems = ReflectiveHttpContext.HttpContextItemsGetter(httpContext);
            var         map = httpContextItems[SessionFactoryMapKey] as IDictionary;

            if (map == null && create)
            {
                map = new Hashtable();
                httpContextItems[SessionFactoryMapKey] = map;
            }
            return(map);
        }