-
Notifications
You must be signed in to change notification settings - Fork 2
Getting started
-
Versions (>= 1.0 && < 2.0)
- .NET Core 2.0 and above
- .NET Framework 4.6.1 and above
-
Versions (>= 2.0)
- .NET Core 2.2
-
Using NuGet package manager:
Search ChustaSoft.Services.StaticData.AspNet -
By Package Manager console
Install-Package ChustaSoft.StaticData -Version 2.0.0 -
By .NET CLI
dotnet add package ChustaSoft.StaticData --version 2.0.0
First of all, if ExchangeRateService will be used in the project, indepently of the method choosen for configuring the tool, it is neccesary a registrarion in Currency Converter API in order to have a valid and registered API key for those API calls.
services.RegisterStaticDataServices(Configuration);
In this case, without any additional info inside appsettings.json, default configuration will be setted up. Configuration by default does not configure any currency for data services, but it configures USD as base currency to compare requested ExchangeRates on demand
Optionally, custom configuration could be provided inside appsettings.json, here is an example:
"StaticDataConfiguration": {
"ApiDataPeferably": true,
"CurrencyConversionApiKey": "TestApiKeyGoesHere" "BaseCurrency": "EUR", "ConfiguredCurrencies": [ "USD", "GBP" ] },`
StaticData allows being configured within the startup by using StaticDataConfigurationBuilder. It is possible to configure exactly the same than the appsettings method. Here we have a simple example of how to configure it
-
Configuring only base currency and free converter API KEy
services.RegisterStaticDataServices(StaticDataConfigurationBuilder.Generate()
.SetBaseCurrency("EUR")
.AddCurrencyConverterApiKey("TestApiKeyGoesHere")); -
Configuring base currency, one single configured currency and free converter API KEy
services.RegisterStaticDataServices(StaticDataConfigurationBuilder.Generate()
.SetBaseCurrency("EUR")
.AddConfiguredCurrency("GBP")
.AddCurrencyConverterApiKey("TestApiKeyGoesHere")); -
Configuring base currency, multiple configured currencies and free converter API KEy
services.RegisterStaticDataServices(StaticDataConfigurationBuilder.Generate()
.SetBaseCurrency("EUR")
.AddConfiguredCurrencies(new List<string> { "GBP", "CNY", "JPY" })
.AddCurrencyConverterApiKey("TestApiKeyGoesHere"));