/// <summary> /// Assign a switch a value /// </summary> /// <param name="switchName">The name of the switch</param> /// <param name="isEnabled">The value to assign</param> public static void SetSwitch(string switchName, bool isEnabled) { if (switchName == null) { throw new ArgumentNullException("switchName"); } if (switchName.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName"); } if (s_defaultsInitialized == false) { InitializeDefaultSwitchValues(); } #if DEBUG BCLDebug.Assert(s_defaultsInitialized == true, "AppContext defaults should have been initialized."); #endif SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) | SwitchValueState.HasLookedForOverride; lock (s_switchMap) { // Store the new value and the fact that we checked in the dictionary s_switchMap[switchName] = switchValue; } }
/// <summary> /// Assign a switch a value /// </summary> /// <param name="switchName">The name of the switch</param> /// <param name="isEnabled">The value to assign</param> public static void SetSwitch(string switchName, bool isEnabled) { if (switchName == null) throw new ArgumentNullException(nameof(switchName)); if (switchName.Length == 0) throw new ArgumentException(SR.Argument_EmptyName, nameof(switchName)); SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) | SwitchValueState.HasLookedForOverride; lock (s_switchMap) { // Store the new value and the fact that we checked in the dictionary s_switchMap[switchName] = switchValue; } }
/// <summary> /// Assign a switch a value /// </summary> /// <param name="switchName">The name of the switch</param> /// <param name="isEnabled">The value to assign</param> public static void SetSwitch(string switchName, bool isEnabled) { if (switchName == null) { throw new ArgumentNullException("switchName"); } if (switchName.Length == 0) { throw new ArgumentException(SR.Argument_EmptyName, "switchName"); } SwitchValueState switchValue = isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue; lock (s_switchMap) { // Store the new value and the fact that we checked in the dictionary s_switchMap[switchName] = switchValue; } }
/// <summary> /// Assign a switch a value /// </summary> /// <param name="switchName">The name of the switch</param> /// <param name="isEnabled">The value to assign</param> public static void SetSwitch(string switchName, bool isEnabled) { if (switchName == null) { throw new ArgumentNullException("switchName"); } if (switchName.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName"); } SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) | SwitchValueState.HasLookedForOverride; lock (s_switchMap) { // Store the new value and the fact that we checked in the dictionary s_switchMap[switchName] = switchValue; } }