Beispiel #1
0
        private static int GetSwitchValue(string switchName, string switchDescription, int defaultValue)
        {
            IntegerSwitch theSwitch = new IntegerSwitch(switchName, switchDescription);

            if (theSwitch.Enabled)
            {
                return(theSwitch.Value);
            }
            new EnvironmentPermission(PermissionState.Unrestricted).Assert();
            try {
                string environmentVar = Environment.GetEnvironmentVariable(switchName);
                if (environmentVar != null)
                {
                    return(Int32.Parse(environmentVar.Trim()));
                }
            } finally {
                EnvironmentPermission.RevertAssert();
            }
            return(defaultValue);
        }
 private static int GetSwitchValue(string switchName, string switchDescription, int defaultValue) {
     IntegerSwitch theSwitch = new IntegerSwitch(switchName, switchDescription);
     if (theSwitch.Enabled) {
         return theSwitch.Value;
     }
     new EnvironmentPermission(PermissionState.Unrestricted).Assert();
     try {
         string environmentVar = Environment.GetEnvironmentVariable(switchName);
         if (environmentVar!=null) {
             defaultValue = Int32.Parse(environmentVar.Trim(), CultureInfo.InvariantCulture);
         }
     }
     finally {
         EnvironmentPermission.RevertAssert();
     }
     return defaultValue;
 }