summaryrefslogtreecommitdiffstats
path: root/src/IOL.VippsEcommerce
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2021-06-05 22:33:05 +0200
committerivarlovlie <git@ivarlovlie.no>2021-06-05 22:33:05 +0200
commitdea3a825a06e7291889b2fb8886dc05148762f33 (patch)
tree518143b9095650fb9637b3629649ab5fd1596a33 /src/IOL.VippsEcommerce
parentc3ad48ee68a4bf97fd2e6d474c90d27a6eee9a1b (diff)
downloaddotnet-vipps-ecommerce-33d656aabd84682fe621cb1a63c4e5f6c842fedc.tar.xz
dotnet-vipps-ecommerce-33d656aabd84682fe621cb1a63c4e5f6c842fedc.zip
Use Microsoft.Extensions.Configuration to read environment variablesv1.2.0
Diffstat (limited to 'src/IOL.VippsEcommerce')
-rw-r--r--src/IOL.VippsEcommerce/IOL.VippsEcommerce.csproj2
-rw-r--r--src/IOL.VippsEcommerce/Models/VippsConfiguration.cs6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/IOL.VippsEcommerce/IOL.VippsEcommerce.csproj b/src/IOL.VippsEcommerce/IOL.VippsEcommerce.csproj
index 711ff84..1097744 100644
--- a/src/IOL.VippsEcommerce/IOL.VippsEcommerce.csproj
+++ b/src/IOL.VippsEcommerce/IOL.VippsEcommerce.csproj
@@ -16,6 +16,8 @@
</PropertyGroup>
<ItemGroup>
+ <PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
diff --git a/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs b/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
index 584ff2b..c9d9b1e 100644
--- a/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
+++ b/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
@@ -1,4 +1,5 @@
using System;
+using Microsoft.Extensions.Configuration;
namespace IOL.VippsEcommerce.Models
{
@@ -151,13 +152,14 @@ namespace IOL.VippsEcommerce.Models
}
private string GetValueFromEnvironment(string key) {
+ var config = new ConfigurationBuilder().AddEnvironmentVariables().Build();
#if DEBUG
- var value = Environment.GetEnvironmentVariable(key);
+ var value = config[key];
Console.WriteLine("Getting VippsConfiguration value for " + key + " from environment.");
Console.WriteLine("Key: " + key + " Value: " + value);
return value;
#else
- return Environment.GetEnvironmentVariable(key);
+ return config[key];
#endif
}