/// <summary> /// Typed UserSession /// </summary> protected virtual async Task <TUserSession> SessionAsAsync <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(await SessionFeature.GetOrCreateSessionAsync <TUserSession>(CacheAsync, Request, Response)); }
public static async Task <TUserSession> SessionAsAsync <TUserSession>(this IRequest req, CancellationToken token = default) { if (HostContext.TestMode) { var mockSession = req.TryResolve <TUserSession>(); if (!Equals(mockSession, default(TUserSession))) { mockSession = req.TryResolve <IAuthSession>() is TUserSession ? (TUserSession)req.TryResolve <IAuthSession>() : default; } if (!Equals(mockSession, default(TUserSession))) { return(mockSession); } } return(await SessionFeature.GetOrCreateSessionAsync <TUserSession>(req.GetCacheClientAsync(), req, req.Response, token).ConfigAwait()); }
/// <summary> /// Typed UserSession /// </summary> public virtual Task <TUserSession> SessionAsAsync <TUserSession>(CancellationToken token = default) { return(SessionFeature.GetOrCreateSessionAsync <TUserSession>(CacheAsync, Request, Response, token)); }
public static Task <TUserSession> SessionAsAsync <TUserSession>(this ICacheClientAsync cache, IRequest httpReq = null, IResponse httpRes = null, CancellationToken token = default) { return(SessionFeature.GetOrCreateSessionAsync <TUserSession>(cache, httpReq, httpRes, token)); }