Exemplo n.º 1
0
        /// <summary>
        /// Gets the currently assigned <see cref="IImageCache"/>.
        /// </summary>
        private void LoadImageCache()
        {
            if (this.ImageCache == null)
            {
                string currentCache = GetImageCacheSection().CurrentCache;
                ImageCacheSection.CacheElementCollection caches = imageCacheSection.ImageCaches;

                foreach (ImageCacheSection.CacheElement cache in caches)
                {
                    if (cache.Name == currentCache)
                    {
                        Type type = Type.GetType(cache.Type);

                        if (type == null)
                        {
                            string message = $"Couldn\'t load IImageCache: {cache.Type}";
                            ImageProcessorBootstrapper.Instance.Logger.Log <ImageProcessorConfiguration>(message);
                            throw new TypeLoadException(message);
                        }

                        this.ImageCache            = type;
                        this.ImageCacheMaxDays     = cache.MaxDays;
                        this.UseFileChangeMonitors = cache.UseFileChangeMonitors;
                        this.BrowserCacheMaxDays   = cache.BrowserMaxDays;
                        this.TrimCache             = cache.TrimCache;
                        this.FolderDepth           = cache.FolderDepth;
                        this.ImageCacheSettings    = cache.Settings
                                                     .Cast <SettingElement>()
                                                     .ToDictionary(setting => setting.Key, setting => setting.Value);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the currently assigned <see cref="IImageCache"/>.
        /// </summary>
        private void LoadImageCache()
        {
            if (this.ImageCache == null)
            {
                string curentCache = GetImageCacheSection().CurrentCache;
                ImageCacheSection.CacheElementCollection caches = imageCacheSection.ImageCaches;

                foreach (ImageCacheSection.CacheElement cache in caches)
                {
                    if (cache.Name == curentCache)
                    {
                        Type type = Type.GetType(cache.Type);

                        if (type == null)
                        {
                            throw new TypeLoadException("Couldn't load IImageCache: " + cache.Type);
                        }

                        this.ImageCache         = type;
                        this.ImageCacheMaxDays  = cache.MaxDays;
                        this.ImageCacheSettings = cache.Settings
                                                  .Cast <SettingElement>()
                                                  .ToDictionary(setting => setting.Key, setting => setting.Value);
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Gets the currently assigned <see cref="IImageCache"/>.
        /// </summary>
        private void LoadImageCache()
        {
            if (this.ImageCache == null)
            {
                string currentCache = GetImageCacheSection().CurrentCache;
                ImageCacheSection.CacheElementCollection caches = imageCacheSection.ImageCaches;

                foreach (ImageCacheSection.CacheElement cache in caches)
                {
                    if (cache.Name == currentCache)
                    {
                        var type = Type.GetType(cache.Type);

                        if (type == null)
                        {
                            string message = $"Couldn't load IImageCache: {cache.Type}";
                            ImageProcessorBootstrapper.Instance.Logger.Log <ImageProcessorConfiguration>(message);
                            throw new TypeLoadException(message);
                        }

                        this.ImageCache                  = type;
                        this.ImageCacheMaxDays           = cache.MaxDays;
                        this.ImageCacheMaxMinutes        = cache.MaxMinutes;
                        this.UseFileChangeMonitors       = cache.UseFileChangeMonitors;
                        this.BrowserCacheMaxDays         = cache.BrowserMaxDays;
                        this.TrimCache                   = cache.TrimCache;
                        this.FolderDepth                 = cache.FolderDepth;
                        this.ImageCacheRewritePathExpiry = cache.CachedRewritePathExpiry;
                        this.ImageCacheSettings          = cache.Settings
                                                           .Cast <SettingElement>()
                                                           .ToDictionary(setting => setting.Key, setting => setting.Value);

                        // Override the settings found with values found in the app.config / deployment slot settings
                        this.OverrideDefaultSettingsWithAppSettingsValue(this.ImageCacheSettings, currentCache);

                        break;
                    }
                }
            }
        }