public void Add(Exchange exchange) { if (exchange == null) { throw new ArgumentNullException(nameof(exchange)); } Exchanges = new List <Exchange>(Exchanges) { exchange }.ToArray(); ExchangeAdded?.Invoke(this, exchange); }
/// <summary> /// To save the exchange. /// </summary> /// <param name="exchange">Exchange.</param> public virtual void Save(Exchange exchange) { if (exchange == null) { throw new ArgumentNullException(nameof(exchange)); } lock (_exchanges.SyncRoot) { if (!_exchanges.TryAdd(exchange.Name, exchange)) { return; } } ExchangeAdded?.Invoke(exchange); }
/// <summary> /// To save the exchange. /// </summary> /// <param name="exchange">Exchange.</param> public virtual void Save(Exchange exchange) { if (exchange == null) { throw new ArgumentNullException(nameof(exchange)); } lock (_exchanges.SyncRoot) { var oldExchange = _exchanges.TryGetValue(exchange.Name); if (ReferenceEquals(oldExchange, exchange)) { return; } _exchanges[exchange.Name] = exchange; } ExchangeAdded?.Invoke(exchange); }