This commit is contained in:
2023-06-29 13:50:21 +02:00
parent bedd41f829
commit d2ac9710f0
5 changed files with 41 additions and 24 deletions

1
EnvTester/EnvTester/.env Normal file
View File

@@ -0,0 +1 @@
nummer4=TEST

View File

@@ -9,7 +9,7 @@
<ItemGroup>
<Reference Include="EonaCat.Env">
<HintPath>..\..\..\EonaCat.Env\EonaCat.Env\bin\Debug\netstandard2.1\EonaCat.Env.dll</HintPath>
<HintPath>..\..\..\EonaCat.Env\EonaCat.Env\bin\Debug\net6.0\EonaCat.Env.dll</HintPath>
</Reference>
</ItemGroup>

View File

@@ -1,13 +1,32 @@
// See https://aka.ms/new-console-template for more information
using EonaCat.Env;
using EonaCat.Env.Helpers;
using System.Diagnostics.Metrics;
Console.WriteLine("Hello, World!");
Env.LoadIntoEnvironment();
Env.LoadIntoEnvironment(new Settings(traverseDirectories:true));
var test = Env.Read(new Settings(traverseDirectories:true));
Getter.SwallowExceptions = false;
Console.WriteLine(Environment.GetEnvironmentVariable("nummer4"));
Console.WriteLine(Getter.GetString("nummer4"));
if (test.Any())
Console.WriteLine("From Env.Read: " + test.Values);
Console.WriteLine("From Environment variable: " + Environment.GetEnvironmentVariable("nummer4"));
Console.WriteLine("From Getter: " + Getter.GetValue<string>("nummer4"));
Console.WriteLine("From SecretManager class: " + Secrets.API_KEY);
Console.WriteLine("+------+");
Console.WriteLine(Environment.GetEnvironmentVariable("FAAL"));
Console.WriteLine("test");
Console.WriteLine("test");
public static class Secrets
{
static Secrets()
{
Env.LoadIntoEnvironment(new Settings(traverseDirectories: true));
}
public static string API_KEY => GetApiKey();
private static string GetApiKey()
{
return Getter.GetValue<string>("nummer4");
}
}