Inheritance: IScopeCache, IDisposable
        public void Dispose()
        {
            using (var token = @lock.ForReadingUpgradeable())
            {
                if (cache == null)
                {
                    return;
                }
                token.Upgrade();
                cache.Dispose();
                cache = null;

                if (parentScope != null)
                {
                    SetCurrentScope(parentScope);
                }
#if FEATURE_REMOTING
                else
                {
                    CallContext.FreeNamedDataSlot(keyInCallContext);
                }
#endif
            }
            CallContextLifetimeScope @this;
            appDomainLocalInstanceCache.TryRemove(contextId, out @this);
        }
Exemple #2
0
        public void Dispose()
        {
            using (var token = @lock.ForReadingUpgradeable())
            {
                if (cache == null)
                {
                    return;
                }
                token.Upgrade();
                cache.Dispose();
                cache = null;

                if (parentScope != null)
                {
                    SetCurrentScope(parentScope);
                }
                else
                {
                    CallContext.FreeNamedDataSlot(contextKey);
                }
            }
#if DOTNET35
            lock (locker)
            {
                appDomainLocalInstanceCache.Remove(instanceId);
            }
#else
            CallContextLifetimeScope @this;
            appDomainLocalInstanceCache.TryRemove(instanceId, out @this);
#endif
        }
Exemple #3
0
        public void Dispose()
        {
            using (var token = @lock.ForReadingUpgradeable())
            {
                // Dispose the burden cache
                if (cache == null)
                {
                    return;
                }
                token.Upgrade();
                cache.Dispose();
                cache = null;

                // Restore the parent scope (if inside one)
                if (parentScope != null)
                {
                    SetCurrentScope(parentScope);
                }
                else
                {
#if FEATURE_REMOTING
                    CallContext.FreeNamedDataSlot(callContextKey);
#endif
                }
            }

            CallContextLifetimeScope @this;
            allScopes.TryRemove(contextId, out @this);
        }
		private void EndCurrentScope(ScopeCache scopeCache)
		{
			var scopes = GetCurrentScopes();

			if (scopes.Peek() != scopeCache)
			{
				throw new InvalidOperationException(
					"The scope is not current.  Did you forget to end a child scope?");
			}

			scopeCache.Dispose();
			scopes.Pop();
		}
		public void Dispose()
		{
			using (var token = @lock.ForReadingUpgradeable())
			{
				if (cache == null)
				{
					return;
				}
				token.Upgrade();
				cache.Dispose();
				cache = null;
				SetCurrentScope(parentScope);
			}
		}
 public void Dispose()
 {
     using (var token = @lock.ForReadingUpgradeable())
     {
         if (cache == null)
         {
             return;
         }
         token.Upgrade();
         cache.Dispose();
         cache = null;
         SetCurrentScope(parentScope);
     }
 }
		private IScopeCache GetCache(CreationContext.ResolutionContext selected)
		{
			var stash = (IScopeCache)selected.Context.GetContextualProperty("castle-scope-stash");
			if (stash == null)
			{
				var newStash = new ScopeCache();
				var decorator = new ScopeCacheDecorator(newStash);
				decorator.OnInserted += (_, b) =>
				{
					if (b.RequiresDecommission)
					{
						selected.Burden.RequiresDecommission = true;
						selected.Burden.GraphReleased += burden => newStash.Dispose();
					}
				};
				selected.Context.SetContextualProperty("castle-scope-stash", newStash);
				stash = decorator;
			}
			return stash;
		}
Exemple #8
0
        private IScopeCache GetCache(CreationContext.ResolutionContext selected)
        {
            var stash = (IScopeCache)selected.Context.GetContextualProperty("castle-scope-stash");

            if (stash == null)
            {
                var newStash  = new ScopeCache();
                var decorator = new ScopeCacheDecorator(newStash);
                decorator.OnInserted += (_, b) =>
                {
                    if (b.RequiresDecommission)
                    {
                        selected.Burden.RequiresDecommission = true;
                        selected.Burden.GraphReleased       += burden => newStash.Dispose();
                    }
                };
                selected.Context.SetContextualProperty("castle-scope-stash", newStash);
                stash = decorator;
            }
            return(stash);
        }
		public void Dispose()
		{
			using (var token = @lock.ForReadingUpgradeable())
			{
				if (cache == null)
				{
					return;
				}
				token.Upgrade();
				cache.Dispose();
				cache = null;

				if (parentScope != null)
				{
					CallContext.SetData(contextKey, parentScope);
				}
				else
				{
					CallContext.FreeNamedDataSlot(contextKey);
				}
			}
		}
Exemple #10
0
        public void Dispose()
        {
            using (var token = @lock.ForReadingUpgradeable())
            {
                if (cache == null)
                {
                    return;
                }
                token.Upgrade();
                cache.Dispose();
                cache = null;

                if (parentScope != null)
                {
                    CallContext.SetData(contextKey, parentScope);
                }
                else
                {
                    CallContext.FreeNamedDataSlot(contextKey);
                }
            }
        }
		public void Dispose()
		{
			using (var token = @lock.ForReadingUpgradeable())
			{
				if (cache == null)
				{
					return;
				}
				token.Upgrade();
				cache.Dispose();
				cache = null;

				if (parentScope != null)
				{
					SetCurrentScope(parentScope);
				}
				else
				{
					CallContext.FreeNamedDataSlot(contextKey);
				}
			}
			CallContextLifetimeScope @this;
			appDomainLocalInstanceCache.TryRemove(instanceId, out @this);
		}
			public EndScope(ScopingSubsystem manager, ScopeCache scopeCache)
			{
				this.manager = manager;
				this.scopeCache = scopeCache;
			}
		public IDisposable BeginScope()
		{
			var scope = new ScopeCache();
			GetCurrentScopes().Push(scope);
			return new EndScope(this, scope);
		}
 public ScopeCacheDecorator(ScopeCache inner)
 {
     this.inner = inner;
 }
		public ScopeCacheDecorator(ScopeCache inner)
		{
			this.inner = inner;
		}