public MarketAveragePriceEntry GetAveragePriceByMarket(int definition) { if (!EntityDefault.Exists(definition)) { Logger.Error("average price reqested for not supported definition: " + definition); return(null); } MarketAveragePriceEntry marketAveragePriceEntry; if (!_averagePrices.TryGetValue(definition, out marketAveragePriceEntry) || DateTime.Now.Subtract(marketAveragePriceEntry.LastUpdated).TotalMinutes > MarketInfoService.MARKET_AVERAGE_EXPIRY_MINUTES) { //not in the cache, OR obsolete => load it var averagePrice = new MarketAveragePriceEntry(); averagePrice.LoadAveragePrice(definition, MarketInfoService.MARKET_AVERAGE_DAYSBACK, Market); _averagePrices.AddOrUpdate(definition, averagePrice, (k, v) => averagePrice); marketAveragePriceEntry = averagePrice; } return(marketAveragePriceEntry); }