Skip to content

Commit

Permalink
Add methods for reading environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sjuarezgx committed May 18, 2022
1 parent 5c066c8 commit 6094f03
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Domain/GXRuntime.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
using System;
using System.Collections;
using GeneXus.Utils;

namespace GX
{
public class GXRuntime
Expand All @@ -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;
}
}
}
}

0 comments on commit 6094f03

Please sign in to comment.