예제 #1
0
        /// <summary>
        /// Evicts the specified candidate.
        /// </summary>
        /// <param name="candidate">The candidate.</param>
        public void Evict(Candidate candidate)
        {
            base.Release(candidate.Intance);

            ScopeAttribute scopeAttribute = (ScopeAttribute)candidate.ComponentModel.ExtendedProperties[ScopeInspector.SCOPE_ATTRIBUTE];

            IScope scope = (IScope)Kernel[scopeAttribute.Scope];

            scope.Remove(candidate.ComponentModel.Name);
        }
예제 #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);
        }
예제 #3
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);
        }
 /// <summary>
 /// Evicts the specified instance.
 /// </summary>
 /// <param name="candidate">The candidate.</param>
 internal void Evict(Candidate candidate)
 {
     base.Release(candidate.Component);
     _requestScope.Remove(candidate.Name);
 }