Compare commits

...

2 Commits

Author SHA1 Message Date
36a78a8284 fix: add using Configuration.General
Some checks failed
.NET Test Pipeline / build-and-test (pull_request) Failing after 1m29s
2024-05-28 06:53:52 +03:00
7a1281692e fix: it is correct to delete comments 2024-05-28 06:51:40 +03:00
2 changed files with 18 additions and 6 deletions

View File

@ -5,20 +5,32 @@ namespace Mirea.Api.Endpoint.Configuration;
internal static class EnvironmentManager internal static class EnvironmentManager
{ {
public static void LoadEnvironment(string filePath) public static void LoadEnvironment(string envFile)
{ {
if (!File.Exists(filePath)) return; if (!File.Exists(envFile)) return;
foreach (var line in File.ReadAllLines(filePath)) foreach (var line in File.ReadAllLines(envFile))
{ {
var parts = line.Split( if (string.IsNullOrEmpty(line)) continue;
var commentIndex = line.IndexOf('#', StringComparison.Ordinal);
string arg = line;
if (commentIndex != -1)
arg = arg.Remove(commentIndex, arg.Length - commentIndex);
var parts = arg.Split(
'=', '=',
StringSplitOptions.RemoveEmptyEntries); StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 2)
parts = [parts[0], string.Join("=", parts[1..])];
if (parts.Length != 2) if (parts.Length != 2)
continue; continue;
Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1][..(parts[1].Contains('#') ? parts[1].IndexOf('#') : parts[1].Length)].Trim()); Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1].Trim());
} }
} }
} }

View File

@ -10,7 +10,7 @@ using Mirea.Api.DataAccess.Application;
using Mirea.Api.DataAccess.Persistence; using Mirea.Api.DataAccess.Persistence;
using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration; using Mirea.Api.Endpoint.Configuration;
using Mirea.Api.Endpoint.Properties; using Mirea.Api.Endpoint.Configuration.General;
using Mirea.Api.Endpoint.Configuration.Swagger; using Mirea.Api.Endpoint.Configuration.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
using System; using System;