Beispiel #1
0
        /// <summary>
        /// Typed UserSession
        /// </summary>
        protected virtual TUserSession SessionAs <TUserSession>()
        {
            var ret = TryResolve <TUserSession>();

            return(!Equals(ret, default(TUserSession))
                ? ret
                : SessionFeature.GetOrCreateSession <TUserSession>(Cache, Request, Response));
        }
Beispiel #2
0
        /// <summary>
        /// Typed UserSession
        /// </summary>
        protected virtual TUserSession SessionAs <TUserSession>()
        {
            if (HostContext.TestMode)
            {
                var mockSession = TryResolve <TUserSession>();
                if (Equals(mockSession, default(TUserSession)))
                {
                    mockSession = TryResolve <IAuthSession>() is TUserSession
                        ? (TUserSession)TryResolve <IAuthSession>()
                        : default;
                }

                if (!Equals(mockSession, default(TUserSession)))
                {
                    return(mockSession);
                }
            }

            return(SessionFeature.GetOrCreateSession <TUserSession>(Cache, Request, Response));
        }
        public static TUserSession SessionAs <TUserSession>(this IRequest req)
        {
            if (HostContext.TestMode)
            {
                var mockSession = req.TryResolve <TUserSession>();
                if (!Equals(mockSession, default(TUserSession)))
                {
                    mockSession = req.TryResolve <IAuthSession>() is TUserSession
                        ? (TUserSession)req.TryResolve <IAuthSession>()
                        : default(TUserSession);
                }

                if (!Equals(mockSession, default(TUserSession)))
                {
                    return(mockSession);
                }
            }

            return(SessionFeature.GetOrCreateSession <TUserSession>(req.GetCacheClient(), req, req.Response));
        }
 public static TUserSession SessionAs <TUserSession>(this ICacheClient cache,
                                                     IRequest httpReq = null, IResponse httpRes = null)
 {
     return(SessionFeature.GetOrCreateSession <TUserSession>(cache, httpReq, httpRes));
 }
Beispiel #5
0
 /// <summary>
 /// Typed UserSession
 /// </summary>
 public virtual TUserSession SessionAs <TUserSession>()
 {
     return(SessionFeature.GetOrCreateSession <TUserSession>(Cache, Request, Response));
 }