public bool TryGetValue(string key, out Parser parser) { if (this.parsers.TryGetValue(key, out parser)) { this.parserAccessDates[key] = DateTime.UtcNow; return true; } return false; }
public bool TryGetValue(string key, out Parser parser) { if (this.parsers.TryGetValue(key, out parser)) { this.parserAccessDates[key] = DateTime.UtcNow; return(true); } return(false); }
public void Add(string key, Parser parser) { this.parsers[key] = parser; this.parserAccessDates[key] = DateTime.UtcNow; // If we exceed the maximum amount of parsers, remove the oldest ones if (this.parsers.Count > GlobalHost.MaxParsers) { var toBeRemoved = this.parserAccessDates.OrderBy(x => x.Value).Take(GlobalHost.ParsersToRemoveOnOverflow).ToList(); DateTime dummyDateTime; Parser dummyParser; foreach (var entry in toBeRemoved) { this.parserAccessDates.TryRemove(entry.Key, out dummyDateTime); this.parsers.TryRemove(entry.Key, out dummyParser); } } }