public BitmapImage GetChampionIcon(int championId) { string name = null; if (championId != 0) { name = _gameData.GetChampionData(championId)?.Name; } return(new BitmapImage(new Uri(Path.Combine(_clientDir, name == null ? RandomIconFile : string.Format(IconFile, name))))); }
public BitmapImage GetChampionIcon(int championId) { string name = null; if (championId != 0) { name = _gameData.GetChampionData(championId)?.Name; } BitmapImage bi; if (!iconCache.ContainsKey(championId)) { bi = new BitmapImage(new Uri(Path.Combine(_clientDir, name == null ? RandomIconFile : string.Format(IconFile, name)))); iconCache[championId] = bi; bi.Freeze(); } else { bi = iconCache[championId]; } return(bi); }