System.Net.GlobalLog.GetSwitchValue C# (CSharp) Method

GetSwitchValue() private static method

private static GetSwitchValue ( string switchName, string switchDescription, bool defaultValue ) : bool
switchName string
switchDescription string
defaultValue bool
return bool
        private static bool GetSwitchValue(string switchName, string switchDescription, bool defaultValue) {
            BooleanSwitch theSwitch = new BooleanSwitch(switchName, switchDescription);
            new EnvironmentPermission(PermissionState.Unrestricted).Assert();
            try {
                if (theSwitch.Enabled) {
                    return true;
                }
                string environmentVar = Environment.GetEnvironmentVariable(switchName);
                defaultValue = environmentVar!=null && environmentVar.Trim()=="1";
            }
            catch (ConfigurationException) { }
            finally {
                EnvironmentPermission.RevertAssert();
            }
            return defaultValue;
        }
#endif // TRAVE || DEBUG