Ejemplo n.º 1
0
		public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
		{
			var burden = scopeCache[model];
			if (burden == null)
			{
				scopeCache[model] = burden = createInstance(onAfterCreated);
			}
			return burden;
		}
Ejemplo n.º 2
0
        public Burden GetCachedInstance(ComponentModel instance, ScopedInstanceActivationCallback createInstance)
        {
            var burden = scopeCache[instance];

            if (burden == null)
            {
                scopeCache[instance] = burden = createInstance(onAfterCreated);
            }
            return(burden);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the cached instance.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="createInstance">The create instance.</param>
 /// <returns></returns>
 public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
 {
     lock (_lock)
     {
         Burden burden = _scopeCache[model];
         if (burden == null)
         {
             _scopeCache[model] = burden = createInstance(_onAfterCreated);
         }
         return burden;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the cached instance.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="createInstance">The create instance.</param>
 /// <returns></returns>
 public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
 {
     lock (_lock)
     {
         Burden burden = _scopeCache[model];
         if (burden == null)
         {
             _scopeCache[model] = burden = createInstance(_onAfterCreated);
         }
         return(burden);
     }
 }
Ejemplo n.º 5
0
        public Burden GetCachedInstance(ComponentModel instance, ScopedInstanceActivationCallback createInstance)
        {
            using (var token = @lock.ForReadingUpgradeable())
            {
                var burden = cache[instance];
                if (burden == null)
                {
                    token.Upgrade();

                    burden          = createInstance(delegate { });
                    cache[instance] = burden;
                }
                return(burden);
            }
        }
		public Burden GetCachedInstance(ComponentModel instance, ScopedInstanceActivationCallback createInstance)
		{
			using (var token = @lock.ForReadingUpgradeable())
			{
				var burden = cache[instance];
				if (burden == null)
				{
					token.Upgrade();

					burden = createInstance(delegate { });
					cache[instance] = burden;
				}
				return burden;
			}
		}
 public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
 {
     if (model.Configuration.Attributes.Get(NetCoreTransientMarker) == Boolean.TrueString)
     {
         var burder = createInstance((_) => {});
         _scopeCache[burder] = burder;
         return(burder);
     }
     else
     {
         var burden = _scopeCache[model];
         if (burden == null)
         {
             _scopeCache[model] = burden = createInstance((_) => {});
         }
         return(burden);
     }
 }
Ejemplo n.º 8
0
        public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance)
        {
            lock (scopeCache)
            {
                // Add transient's burden to scope so it gets released
                if (model.Configuration.Attributes.Get(TransientMarker) == bool.TrueString)
                {
                    var transientBurden = createInstance(_ => {});
                    scopeCache[transientBurden] = transientBurden;
                    return(transientBurden);
                }

                var scopedBurden = scopeCache[model];
                if (scopedBurden != null)
                {
                    return(scopedBurden);
                }
                scopedBurden      = createInstance((_) => {});
                scopeCache[model] = scopedBurden;
                return(scopedBurden);
            }
        }
Ejemplo n.º 9
0
			Burden ILifetimeScope.GetCachedInstance(ComponentModel instance, ScopedInstanceActivationCallback createInstance)
			{
				// not sure if we'll be able to hit this code ever. If so we should get a better exception message
				throw new InvalidOperationException(
					"This scope comes from a different app domain and cannot be used in this context.");
			}
Ejemplo n.º 10
0
 Burden ILifetimeScope.GetCachedInstance(ComponentModel instance, ScopedInstanceActivationCallback createInstance)
 {
     // not sure if we'll be able to hit this code ever. If so we should get a better exception message
     throw new InvalidOperationException(
               "This scope comes from a different app domain and cannot be used in this context.");
 }