Esempio n. 1
0
        /// <summary>
        /// Registers for request eviction.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="component">The component.</param>
        /// <param name="instance">The instance.</param>
        internal static void RegisterForRequestEviction(
            ScopeLifestyleManager manager,
            ComponentModel component, object instance)
        {
            HttpContext httpContext = HttpContext.Current;

            IDictionary<ScopeLifestyleManager, Candidate> candidates = (Dictionary<ScopeLifestyleManager, Candidate>)httpContext.Items[PER_REQUEST_EVICT];

            if (candidates == null)
            {
                candidates = new Dictionary<ScopeLifestyleManager, Candidate>();
                httpContext.Items[PER_REQUEST_EVICT] = candidates;
            }
            Candidate candidate = new Candidate(component, instance);

            candidates.Add(manager, candidate);
        }
Esempio n. 2
0
        /// <summary>
        /// Registers for session eviction.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="component">The component.</param>
        /// <param name="instance">The instance.</param>
        internal static void RegisterForSessionEviction(
            ScopeLifestyleManager manager,
            ComponentModel component,
            object instance)
        {
            HttpContext context = HttpContext.Current;

            IDictionary<ScopeLifestyleManager, Candidate> candidates = (Dictionary<ScopeLifestyleManager, Candidate>)context.Session[PER_SESSION_EVICT];

            if (candidates == null)
            {
                candidates = new Dictionary<ScopeLifestyleManager, Candidate>();
                context.Session[PER_SESSION_EVICT] = candidates;
            }
            Candidate candidate = new Candidate(component, instance);
            candidates.Add(manager, candidate);
        }