Wox.Infrastructure.Image.ImageCache.ContainsKey C# (CSharp) Method

ContainsKey() public method

public ContainsKey ( string key ) : bool
key string
return bool
        public bool ContainsKey(string key)
        {
            var contains = _data.ContainsKey(key);
            return contains;
        }

Usage Example

Exemplo n.º 1
0
        public static void Initialize()
        {
            _storage         = new BinaryStorage <ConcurrentDictionary <string, int> > ("Image");
            ImageCache.Usage = _storage.TryLoad(new ConcurrentDictionary <string, int>());

            foreach (var icon in new[] { Constant.DefaultIcon, Constant.ErrorIcon })
            {
                ImageSource img = new BitmapImage(new Uri(icon));
                img.Freeze();
                ImageCache[icon] = img;
            }
            Task.Run(() =>
            {
                Stopwatch.Normal("|ImageLoader.Initialize|Preload images cost", () =>
                {
                    ImageCache.Usage.AsParallel().Where(i => !ImageCache.ContainsKey(i.Key)).ForAll(i =>
                    {
                        var img = Load(i.Key);
                        if (img != null)
                        {
                            ImageCache[i.Key] = img;
                        }
                    });
                });
                Log.Info($"|ImageLoader.Initialize|Number of preload images is <{ImageCache.Usage.Count}>");
            });
        }
All Usage Examples Of Wox.Infrastructure.Image.ImageCache::ContainsKey