Sage.Integration.Northwind.Adapter.Services.EuroCurrencyConverter.Initialize C# (CSharp) Method

Initialize() protected method

protected Initialize ( CurrencyCodes targetCurrencyCode ) : void
targetCurrencyCode CurrencyCodes
return void
        protected virtual void Initialize(CurrencyCodes targetCurrencyCode)
        {
            // initialize currency
            _currencyExchangerRates.Add(CurrencyCodes.EUR, 1);
            _currencyExchangerRates.Add(CurrencyCodes.GBP, new decimal(0.84));
            _currencyExchangerRates.Add(CurrencyCodes.USD, new decimal(1.40));

            if (!_currencyExchangerRates.ContainsKey(targetCurrencyCode))
                throw new NotSupportedException(string.Format("Currency code {0} in payload not supported or not ISO 4217 conform. Please chose one of following codes: {0}.", targetCurrencyCode.ToString(), _currencyExchangerRates.Keys.ToString()));

            this.Code = targetCurrencyCode.ToString();
            this.ExchangeRate = _currencyExchangerRates[targetCurrencyCode];
        }