Exemplo n.º 1
0
        public void TryGetFail()
        {
            CacheEntry cacheEntry;
            var        result = _cache.TryGet("k", out cacheEntry);

            Assert.AreEqual(false, result);
        }
Exemplo n.º 2
0
 public static DrawingBrush Get(CardViewModel card)
 {
     try
     {
         if (card?.Id == null || card.Name == null || Cache == null)
         {
             return(new DrawingBrush());
         }
         var cardImageObj = new CardImageObject(card);
         var key          = $"{card.Id}_{cardImageObj.GetHashCode()}";
         if (!Refresh.Contains(card.Id) && Cache.TryGet(key, out var cached))
         {
             return(cached.Image);
         }
         Refresh.Remove(card.Id);
         DrawingBrush image = null;
         Application.Current.Dispatcher.Invoke(() => image = ThemeManager.GetBarImageBuilder(card).Build());
         if (image.CanFreeze)
         {
             image.Freeze();
         }
         cardImageObj = new CardImageObject(image, card);
         Cache.Cache(key, cardImageObj);
         return(cardImageObj.Image);
     }
     catch (Exception ex)
     {
         Log.Error($"Image builder failed: {ex.Message}");
         return(new DrawingBrush());
     }
 }