コード例 #1
0
 // Token: 0x060014FE RID: 5374 RVA: 0x0007F880 File Offset: 0x0007DA80
 internal UserContextBase(UserContextKey key)
 {
     this.key = key;
     this.sessionBeginTime        = Stopwatch.GetTimestamp();
     this.sessionLastAccessedTime = this.sessionBeginTime;
     this.writerLock = UserContextManager.GetUserContextKeyLock(key.ToString());
 }
コード例 #2
0
        internal static UserContext TryGetUserContextFromCache(UserContextKey userContextKey)
        {
            ExTraceGlobals.UserContextCallTracer.TraceDebug(0L, "UserContextManager.TryGetUserContextFromCache");
            UserContext userContext = null;

            try
            {
                ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey>(0L, "Attempting to fetch user context from the cache.  Key={0}", userContextKey);
                UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContextKey.ToString());
                if (userContextCacheWrapper != null && userContextCacheWrapper.UserContext != null)
                {
                    userContext = userContextCacheWrapper.UserContext;
                    ExTraceGlobals.UserContextTracer.TraceDebug <UserContextKey, UserContext>(0L, "User context found in cache. Key={0}, User context instance={1}", userContextKey, userContext);
                    userContext.UpdateLastAccessedTime();
                    userContext.Lock(true);
                }
                else
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug <string>(0L, "An object for this user context ID value is not present in the cache (probably was expired), so we are going to reuse the user context ID value for the new session", userContextKey.UserContextId);
                }
            }
            finally
            {
                if (userContext != null && userContext.State != UserContextState.Active && userContext.LockedByCurrentThread())
                {
                    userContext.Unlock();
                    userContext = null;
                }
            }
            return(userContext);
        }