Exemplo n.º 1
0
        private void TryCache(ICacheable cacheable)
        {
            if (cacheable == null)
            {
                return;
            }
            var cacheModels = kernel.GetAssignableHandlers(typeof(IVisitCacheable));

            foreach (var cache in cacheModels)
            {
                IVisitCacheable visitor = null;
                try
                {
                    visitor = cache.Resolve(CreationContext.Empty) as IVisitCacheable;
                    if (visitor == null)
                    {
                        throw new DittoConfigurationException("Problem with resolution of {0}", cache.ComponentModel.Implementation);
                    }
                    cacheable.Accept(visitor);
                }
                finally
                {
                    if (visitor != null)
                    {
                        kernel.ReleaseComponent(visitor);
                    }
                }
            }
        }