public RequestLogger GetLogger(string ipAddress, bool createIfNotFound) { RequestLogger logger = null; lock (this) { bool found = loggerDictionary.TryGetValue(ipAddress, out logger); if (!found && createIfNotFound) { logger = new RequestLogger(); loggerDictionary.Add(ipAddress, logger); } } return(logger); }
internal void Expire(int expirationInterval) { ICollection <string> ipAddressList = null; lock (this) { ipAddressList = loggerDictionary.Keys; } foreach (string ipAddress in ipAddressList) { RequestLogger logger = null; bool found = loggerDictionary.TryGetValue(ipAddress, out logger); if (found) { logger.Expire(expirationInterval); } } }