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); }
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))); }
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))); }
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); }