Ninject.Activation.Caching.Cache.Remember C# (CSharp) Méthode

Remember() public méthode

Stores the specified context in the cache.
public Remember ( IContext context, InstanceReference reference ) : void
context IContext The context to store.
reference InstanceReference The instance reference.
Résultat void
        public void Remember(IContext context, InstanceReference reference)
        {
            Ensure.ArgumentNotNull(context, "context");

            var entry = new CacheEntry(context, reference);

            #if !NO_WEB
            var httpScope = context.GetScope() as HttpContext;
            if(httpScope != null)
            {
                var entries = GetEntriesCache(httpScope);
                entries[context.Binding].Add(entry);

                var disposable = reference.Instance as IDisposable;
                if(disposable != null)
                {
                    var disposables = GetRequestScopedDisposables(httpScope);
                    disposables.Add(disposable);
                }
                return;
            }
            #endif

            lock (_entries)
            {
                _entries[context.Binding].Add(entry);
            }

            var notifyScope = context.GetScope() as INotifyWhenDisposed;

            if (notifyScope != null)
                notifyScope.Disposed += (o, e) => Forget(entry);
        }