Ejemplo n.º 1
0
        public void Add(Exchange exchange)
        {
            if (exchange == null)
            {
                throw new ArgumentNullException(nameof(exchange));
            }

            Exchanges = new List <Exchange>(Exchanges)
            {
                exchange
            }.ToArray();
            ExchangeAdded?.Invoke(this, exchange);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
            void IExchangeInfoProvider.Save(Exchange exchange)
            {
                if (exchange == null)
                {
                    throw new ArgumentNullException(nameof(exchange));
                }

                lock (_exchanges.SyncRoot)
                {
                    if (!_exchanges.TryAdd(exchange.Name, exchange))
                    {
                        return;
                    }
                }

                ExchangeAdded.SafeInvoke(exchange);
            }
Ejemplo n.º 4
0
        /// <summary>
        /// To save the exchange.
        /// </summary>
        /// <param name="exchange">Exchange.</param>
        public void Save(Exchange exchange)
        {
            if (exchange == null)
            {
                throw new ArgumentNullException(nameof(exchange));
            }

            _entityRegistry.Exchanges.Save(exchange);

            lock (_exchanges.SyncRoot)
            {
                if (!_exchanges.TryAdd(exchange.Name, exchange))
                {
                    return;
                }
            }

            ExchangeAdded.SafeInvoke(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);
        }
Ejemplo n.º 6
0
        public SavingsTransaction CreateSavingsTransactionWhen(ExchangeAdded notification)
        {
            var savingsTransaction = _savingsTransactionFactory.CreateFrom(SavingsTransactionType.Exchange, notification.Value, notification.PaymentDate, $"{notification.ExchangeValue} @ {notification.ExchangeRate}", notification.Details, notification.ExchangeId);

            return(savingsTransaction);
        }