public CacheItem GetItem(int index) { CacheItem cacheItem = null; _imageManager.UseImage( index, (image, imageName) => { var bitmapImage = CacheFactory.GetBitmapImage(image); cacheItem = new CacheItem(index, bitmapImage, imageName); }); return cacheItem; }
/// <summary> /// Adds the bitmap image at the specified index into the cache. /// </summary> /// <param name="index">The index.</param> /// <param name="image">The bitmap source image</param> private CacheItem Add(int index, BitmapSource image, string imageName) { CacheItem cacheItem = null; if (_cache.ContainsKey(index)) { cacheItem = _cache[index]; } else { cacheItem = new CacheItem(index, image, imageName); _cache.TryAdd(index, cacheItem); } return cacheItem; }