public T GetResource(String name) { CacheContent <T> content = null; bool reload = true; if (cacheDictionnary.ContainsKey(name)) { content = cacheDictionnary[name]; } else if (content is default(CacheContent <T>)) { content = new CacheContent <T>() { data = feeder.GetResource(name), createDate = DateTime.Now }; cacheDictionnary[name] = content; reload = false; } if (TimeLimit != 0 && reload && DateTime.Compare(content.createDate.AddMinutes(TimeLimit), DateTime.Now) <= 0) { content.data = feeder.GetResource(name); content.createDate = DateTime.Now; } return(content.data); }
public void feed(String name, T data) { CacheContent <T> content = new CacheContent <T>() { createDate = DateTime.Now, data = data }; }