public static IDictionary GetEnvironmentVariables ()
{
StringBuilder sb = null;
if (SecurityManager.SecurityEnabled) {
// we must have access to each variable to get the lot
sb = new StringBuilder ();
// but (performance-wise) we do not want a stack-walk
// for each of them so we concatenate them
}
Hashtable vars = new Hashtable ();
foreach (string name in GetEnvironmentVariableNames ()) {
vars [name] = internalGetEnvironmentVariable (name);
if (sb != null) {
sb.Append (name);
sb.Append (";");
}
}
if (sb != null) {
new EnvironmentPermission (EnvironmentPermissionAccess.Read, sb.ToString ()).Demand ();
}
return vars;
}
#else