6
2026-01-24 12:49:55 +03:00

21 lines
608 B
C#

#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
namespace Content.MapRenderer.Extensions
{
public static class EnvironmentExtensions
{
public static bool TryGetVariable(string key, [NotNullWhen(true)] out string? value)
{
return (value = Environment.GetEnvironmentVariable(key)) != null;
}
public static string GetVariableOrThrow(string key)
{
return Environment.GetEnvironmentVariable(key) ??
throw new ArgumentException($"No environment variable found with key {key}");
}
}
}