From 6094f03a376ed6c3c93bb023510a1eabeb949de4 Mon Sep 17 00:00:00 2001 From: sjuarezgx Date: Wed, 18 May 2022 11:10:50 -0300 Subject: [PATCH] Add methods for reading environment variables --- .../GxClasses/Domain/GXRuntime.cs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GXRuntime.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GXRuntime.cs index 84923e73e..542698fbf 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GXRuntime.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GXRuntime.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections; +using GeneXus.Utils; + namespace GX { public class GXRuntime @@ -10,6 +14,44 @@ public static short Environment } } public static int ExitCode { get; set; } - + public static bool HasEnvironmentVariable(string varName) + { + if (string.IsNullOrEmpty(varName)) + return false; + else + { + string value = System.Environment.GetEnvironmentVariable(varName); + if (value == null) + return false; + else + return true; + } + } + public static GXProperties GetEnvironmentVariables() + { + IDictionary variables = System.Environment.GetEnvironmentVariables(); + GXProperties gXProperties = new GXProperties(); + foreach (DictionaryEntry dentry in variables) + { + string key = (String)dentry.Key; + string value = (String)dentry.Value; + gXProperties.Add(key, value); + + } + return (gXProperties); + } + public static string GetEnvironmentVariable(string varName) + { + if (string.IsNullOrEmpty(varName)) + return string.Empty; + else + { + string value = System.Environment.GetEnvironmentVariable(varName); + if (value == null) + return string.Empty; + else + return value; + } + } } }