public static void UpdatePrice( IMagicCardDefinition definition, MagicCardPrice price, bool autoWrite, string additionalLogText, bool forcePriceUpdate) { try { lock (_sync) { if (!forcePriceUpdate && price.IsPriceUpToDate()) { return; } var request = new CardPriceRequest(_notificationCenter); request.PerformRequest(definition, price, true, additionalLogText); if (autoWrite) { Write(); } } } catch (Exception error) { _notificationCenter.FireNotification( LogLevel.Error, string.Format("Error getting price for {0}({1}): {2} ", definition.NameEN, definition.SetCode, error.Message) + additionalLogText); } }
public static MagicCardPrice FindPrice( IMagicCardDefinition definition, bool autoUpdate, bool saveDatabase, string additionalLogText, bool forcePriceUpdate) { MagicCardPrice price = null; if (definition == null) { return(price); } if (!PriceCache.TryGetValue(definition.CardId, out price)) { price = new MagicCardPrice { CardId = definition.CardId, }; PriceCache.TryAdd(definition.CardId, price); } if (autoUpdate) { Task.Factory.StartNew(() => UpdatePrice(definition, price, saveDatabase, additionalLogText, forcePriceUpdate)); } if (!autoUpdate && saveDatabase) { Write(); } return(price); }