コード例 #1
0
ファイル: Service.cs プロジェクト: haristauqir/ServiceStack
        /// <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));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
 /// <summary>
 /// Typed UserSession
 /// </summary>
 public virtual Task <TUserSession> SessionAsAsync <TUserSession>(CancellationToken token = default)
 {
     return(SessionFeature.GetOrCreateSessionAsync <TUserSession>(CacheAsync, Request, Response, token));
 }
コード例 #4
0
 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));
 }