2024-01-26 19:29:08 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2024-01-28 06:28:14 +03:00
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration;
|
2024-01-26 19:29:08 +03:00
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|