public static void AddItem(Person person) { GetNextId(); person.Id = lastId; Collection.Add(person); CacheCollection.Add(person); }
public static FSize MeasureStringCached(SpriteFont font, string text) { CacheCollection <string, FSize> cache; if (!_measureCache.TryGetValue(font, out cache)) { cache = new CacheCollection <string, FSize>(MEASURE_CACHE_SIZE); var size = font.MeasureString(text).ToFSize(); cache.Add(text, size); return(size); } else { FSize size; if (!cache.TryGetValue(text, out size)) { size = font.MeasureString(text).ToFSize(); cache.Add(text, size); return(size); } else { return(size); } } }