コード例 #1
0
        public static TUserSession SessionAs <TUserSession>(this ICacheClient cache)
        {
            if (SessionKey != null)
            {
                return(cache.Get <TUserSession>(SessionKey));
            }

            SessionFeature.CreateSessionIds();
            var unAuthorizedSession = typeof(TUserSession).CreateInstance();

            return((TUserSession)unAuthorizedSession);
        }
コード例 #2
0
        protected TUserSession SessionAs <TUserSession>()
        {
            if (userSession != null)
            {
                return((TUserSession)userSession);
            }
            if (SessionKey != null)
            {
                userSession = this.GetAppHost().GetCacheClient().Get <TUserSession>(SessionKey);
            }
            else
            {
                SessionFeature.CreateSessionIds();
            }
            var unAuthorizedSession = typeof(TUserSession).CreateInstance();

            return((TUserSession)(userSession ?? (userSession = unAuthorizedSession)));
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: vdt/ServiceStack
        protected virtual TUserSession SessionAs <TUserSession>()
        {
            if (userSession != null)
            {
                return((TUserSession)userSession);
            }
            if (SessionKey != null)
            {
                userSession = Cache.Get <TUserSession>(SessionKey);
            }
            else
            {
                SessionFeature.CreateSessionIds();
            }
            var unAuthorizedSession = typeof(TUserSession).CreateInstance();

            return((TUserSession)(userSession ?? (userSession = unAuthorizedSession)));
        }
コード例 #4
0
        public static TUserSession SessionAs <TUserSession>(this ICacheClient cache,
                                                            IHttpRequest httpReq = null, IHttpResponse httpRes = null)
        {
            var sessionKey = GetSessionKey(httpReq);

            if (sessionKey != null)
            {
                var userSession = cache.Get <TUserSession>(sessionKey);
                if (!Equals(userSession, default(TUserSession)))
                {
                    return(userSession);
                }
            }

            if (sessionKey == null)
            {
                SessionFeature.CreateSessionIds(httpReq, httpRes);
            }

            var unAuthorizedSession = (TUserSession)typeof(TUserSession).CreateInstance();

            return(unAuthorizedSession);
        }