/// <summary> /// データを追加し、バッファサイズが大きくなったときは古いものを削除 /// </summary> /// <param name="dictionary"></param> public static void AddOrExtrude (this ConcurrentDictionary <string, ImageBufferItem> dictionary, string key, ImageBufferItem value, int size) { if (dictionary.Count > size) { dictionary.ReleaseOldImage(); } dictionary.AddOrUpdate(key, value, (oldkey, oldvalue) => (oldvalue.Quality <= value.Quality) ? value : oldvalue); }
private bool TryGetImageData (string path, ImageQuality quality, out ImageBufferItem result) { if (path == null) { result = null; return(false); } /* #if DEBUG * if (this.thumbNailImages.Count > 0) * { * result = this.thumbNailImages.First().Value; * if (result != null) * { * return true; * } * } #endif*/ var key = path; if (quality == ImageQuality.ThumbNail) { return(this.thumbNailImages.TryGetOrRemove(key, out result)); } if (this.images.TryGetOrRemoveWithQuality(key, quality, out result)) { return(true); } if (quality == ImageQuality.LowQuality) { if (this.thumbNailImages.TryGetOrRemove(key, out result)) { return(true); } } result = null; return(false); }