public void Remove(IObjectAssemblySpecification ireg)
        {
            IObjectAssemblerRegistrationKey key = MakeKey(ireg.Name, ireg.ResolvesTo);

            typeRegistrations.Remove(key);
            ireg.FlushCache();
        }
示例#2
0
        public void FlushCache(IObjectAssemblySpecification registration)
        {
            if (_localStorage == null)
            {
                return;
            }

            _localStorage.Remove(registration.Key);
        }
示例#3
0
        public void FlushCache(IObjectAssemblySpecification registration)
        {
            var reg = registration as ObjectAssemblySpecification;

            if (reg != null)
            {
                reg._instance = null;
            }
        }
        public object ActivateInstance(IObjectAssemblySpecification registration)
        {
            Cache cache = HttpRuntime.Cache;

            string key      = registration.Key;
            object instance = cache[key];

            if (instance == null)
            {
                lock (_syncRoot)
                {
                    instance = cache[key];
                    if (instance == null)
                    {
                        instance = registration.CreateInstance();

                        if (_expirationTime == Cache.NoAbsoluteExpiration &&
                            _expirationDuration == Cache.NoSlidingExpiration)
                        {
                            _expirationBehavior = CachedItemExpirationBehavior.NeverExpires;
                        }

                        switch (_expirationBehavior)
                        {
                        case CachedItemExpirationBehavior.NeverExpires:
                            cache.Insert(key, instance, _dependencies, Cache.NoAbsoluteExpiration,
                                         Cache.NoSlidingExpiration, _cachePriority, _onRemoveCallback);
                            break;

                        case CachedItemExpirationBehavior.AtScheduledDate:
                            cache.Insert(key, instance, _dependencies, _expirationTime,
                                         Cache.NoSlidingExpiration, _cachePriority, _onRemoveCallback);
                            break;

                        case CachedItemExpirationBehavior.AfterTimeSpan:
                            cache.Insert(key, instance, _dependencies, DateTime.UtcNow.Add(_expirationDuration),
                                         Cache.NoSlidingExpiration, _cachePriority, _onRemoveCallback);
                            break;

                        case CachedItemExpirationBehavior.AfterNotUsedInTimeSpan:
                            cache.Insert(key, instance, _dependencies, Cache.NoAbsoluteExpiration,
                                         _expirationDuration, _cachePriority, _onRemoveCallback);
                            break;
                        }
                    }
                }
            }

            return(instance);
        }
示例#5
0
        public object ActivateInstance(IObjectAssemblySpecification creator)
        {
            object instance = null;


            if (_localStorage == null)
            {
                _localStorage = new Dictionary <string, object>();
            }

            if (!_localStorage.TryGetValue(creator.Key, out instance))
            {
                instance = creator.CreateInstance();
                _localStorage[creator.Key] = instance;
            }

            return(instance);
        }
示例#6
0
        public object ActivateInstance(IObjectAssemblySpecification registration)
        {
            object instance;

            if (!RequestLifetimeInstances.TryGetValue(registration.Key, out instance))
            {
                lock (_lock)
                {
                    if (!RequestLifetimeInstances.TryGetValue(registration.Key, out instance))
                    {
                        instance = registration.CreateInstance();
                        RequestLifetimeInstances[registration.Key] = instance;
                    }
                }
            }

            return(instance);
        }
        public object ActivateInstance(IObjectAssemblySpecification registration)
        {
            object instance = Session[registration.Key];

            if (instance == null)
            {
                lock (_syncLock)
                {
                    instance = Session[registration.Key];
                    if (instance == null)
                    {
                        instance = registration.CreateInstance();
                        Session[registration.Key] = instance;
                    }
                }
            }

            return(instance);
        }
示例#8
0
        public object ActivateInstance(IObjectAssemblySpecification registration)
        {
            string key = registration.Key;

            CachedInstance ci = null;

            if (_cache.TryGetValue(key, out ci))
            {
                lock (_syncLock) ci.LastCacheHit = DateTime.UtcNow;
            }
            else
            {
                ci = new CachedInstance {
                    Instance = registration.CreateInstance(), LastCacheHit = DateTime.UtcNow
                };
                _cache.TryAdd(key, ci);
            }

            MaybeGroomCache();
            return(ci.Instance);
        }
 public void FlushCache(IObjectAssemblySpecification registration)
 {
     Session.Remove(registration.Key);
 }
示例#10
0
 public void Remove(IObjectAssemblySpecification ireg)
 {
     _typeRegistry.Remove(ireg);
 }
示例#11
0
 public object ActivateInstance(IObjectAssemblySpecification registration)
 {
     return(registration.CreateInstance());
 }
示例#12
0
 public object ActivateInstance(IObjectAssemblySpecification registration)
 {
     return(((ObjectAssemblySpecification)registration).ProvisionInstanceFromCache());
 }
示例#13
0
 public static IObjectAssemblySpecification AsSessionSingleton(this IObjectAssemblySpecification reg)
 {
     return(reg.WithInstanceCreationStrategy(_httpSessionInstanceFactory));
 }
示例#14
0
 public static IObjectAssemblySpecification AsWebCached(this IObjectAssemblySpecification reg)
 {
     return(reg.WithInstanceCreationStrategy(_webCachedInstanceFactory));
 }
示例#15
0
        public void FlushCache(IObjectAssemblySpecification registration)
        {
            CachedInstance _ = null;

            _cache.TryRemove(registration.Key, out _);
        }
        public void FlushCache(IObjectAssemblySpecification registration)
        {
            Cache cache = HttpRuntime.Cache;

            cache.Remove(registration.Key);
        }
示例#17
0
 public void FlushCache(IObjectAssemblySpecification registration)
 {
     RequestLifetimeInstances.Remove(registration.Key);
 }
示例#18
0
 public static IObjectAssemblySpecification AsInstanceCacheInstance(this IObjectAssemblySpecification reg)
 {
     return(reg.WithInstanceCreationStrategy(_instanceCacheFactory));
 }
示例#19
0
 public static IObjectAssemblySpecification AsThreadSingleton(this IObjectAssemblySpecification reg)
 {
     return(reg.WithInstanceCreationStrategy(_threadLocalInstanceFactory));
 }
示例#20
0
 public static IObjectAssemblySpecification AsAlwaysNew(this IObjectAssemblySpecification reg)
 {
     return(reg.WithInstanceCreationStrategy(null));
 }
示例#21
0
 public void FlushCache(IObjectAssemblySpecification registration)
 {
 }