Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
namespace NzbWebDAV.Utils;
public static class EnvironmentUtil
{
public static string? GetEnvironmentVariable(string envVariable)
{
return StringUtil.EmptyToNull(Environment.GetEnvironmentVariable(envVariable));
}
public static string GetRequiredVariable(string envVariable)
{
return Environment.GetEnvironmentVariable(envVariable) ??
throw new Exception($"The environment variable `{envVariable}` must be set.");
}
public static long? GetLongVariable(string envVariable)
{
return long.TryParse(Environment.GetEnvironmentVariable(envVariable), out var longValue) ? longValue : null;
}
public static bool IsVariableTrue(string envVariable)
{
var value = Environment.GetEnvironmentVariable(envVariable)?.ToLower();
return value is "y" or "yes" or "true";
}
}