项目作者: Djangoum

项目描述 :
.NET Currency exchange library
高级语言: C#
项目地址: git://github.com/Djangoum/NetMoney.git
创建时间: 2017-09-05T10:39:55Z
项目社区:https://github.com/Djangoum/NetMoney

开源协议:MIT License

下载


NetMoney

nuget
Build status

NetMoney is an open source library focused on making currency exchange rating an easy and safe task for .NET developers.

NetMoney provides provides a thread safe communication environment with the Fixer.io open source API using the Circuit Breaker pattern and thread safe code.

Fixer.io is an open source API, Fixer.io data is obtained from the ECB public API.

Installing

Easy Installing through Nuget package manager:

  1. Install-Package NetMoney -Version 0.0.5
  1. dotnet add package NetMoney --version 0.0.5

Usage

The main class of NetMoney is Money wich must be treated as a singleton. The method that let you retrieve exchange rates is GetExchangeRatesAsync

Usage Example

  1. using NetMoney;
  2. using NetMoney.Core;
  3. //Must be treated as a singleton
  4. Money moneySingleton = new Money(10, 5);
  5. await moneySingleton.GetExchangeRatesAsync(Currency.EUR, Currency.AUD, Currency.CNY, Currency.EUR);

Fluent Api Usage

NetMoney also provides a simple fluent api syntax sugar for those who feel more comfortable with this syntax.

  1. using NetMoney;
  2. using NetMoney.Core;
  3. //Must be treated as a singleton
  4. Money moneySingleton = new Money(10, 5);
  5. await moneySingleton.From(Currency.EUR, 1000m).To(Currency.DKK);
  6. // with date filtering
  7. await moneySingleton.From(Currency.EUR, 1000m).FromDate(DateTime.Now).To(Currency.DKK);

Adding and substraction

NetMoney let you add and substract currencies. To add and substract currencies you are not asked to do a previous conversion, NetMoney do it for you only if it’s necesary.

  1. using NetMoney;
  2. using NetMoney.Core;
  3. //Must be treated as a singleton
  4. Money moneySingleton = new Money(10, 5);
  5. IConvertedCurreny australianDolars = await moneySingleton.From(Currency.EUR, 1000m).To(Currency.AUD);
  6. IConvertedCurrency yuans = await moneySingleton.From(Currency.USD, 1000m).To(Currency.CNY);
  7. australianDolars = australianDolars.Sum(yuans);
  8. australianDolars = australiaDolars.Substract(yuans);

Authors

  • Ariel Amor García - Main Contributor - Ariel Amor

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details