feat: add reading from .env file
This commit is contained in:
parent
3c3bdc6155
commit
8f334ae5c2
24
Endpoint/EnvironmentManager.cs
Normal file
24
Endpoint/EnvironmentManager.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mirea.Api.Endpoint;
|
||||
|
||||
internal static class EnvironmentManager
|
||||
{
|
||||
public static void LoadEnvironment(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath)) return;
|
||||
|
||||
foreach (var line in File.ReadAllLines(filePath))
|
||||
{
|
||||
var parts = line.Split(
|
||||
'=',
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parts.Length != 2)
|
||||
continue;
|
||||
|
||||
Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1][..(parts[1].Contains('#') ? parts[1].IndexOf('#') : parts[1].Length)].Trim());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user