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;
		}
示例#2
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);
        }