public FeatureToggleValue(FeatureToggle toggle) { Argument.IsNotNull(() => toggle); Name = toggle.Name; Value = toggle.Value; }
public static void Toggle(this FeatureToggle toggle) { Argument.IsNotNull(() => toggle); if (!toggle.Value.HasValue) { // Was using default value, so siwtch to non-default toggle.Value = !toggle.DefaultValue; } else { toggle.Value = !toggle.Value; } }
public bool RemoveToggle(FeatureToggle toggle) { Argument.IsNotNull(() => toggle); Log.Debug($"Removing feature toggle '{toggle}'"); if (!_featureToggles.Remove(toggle.Name)) { Log.Warning($"Feature toggle '{toggle.Name}' is not registered"); return(false); } Unsubscribe(toggle); ToggleRemoved?.Invoke(this, new ToggleEventArgs(toggle)); return(true); }
public bool AddToggle(FeatureToggle toggle) { Argument.IsNotNull(() => toggle); Log.Debug($"Adding feature toggle '{toggle}'"); if (_featureToggles.TryGetValue(toggle.Name, out var _)) { Log.Warning($"Feature toggle '{toggle.Name}' is already registered"); return(false); } _featureToggles[toggle.Name] = toggle; Subscribe(toggle); ToggleAdded?.Invoke(this, new ToggleEventArgs(toggle)); return(true); }
private void Unsubscribe(FeatureToggle toggle) { toggle.Toggled -= OnFeatureToggleToggled; }
private void Subscribe(FeatureToggle toggle) { toggle.Toggled += OnFeatureToggleToggled; }
public static void Reset(this FeatureToggle toggle) { Argument.IsNotNull(() => toggle); toggle.Value = null; }
public ToggleEventArgs(FeatureToggle toggle) { Argument.IsNotNull(() => toggle); Toggle = toggle; }
public ToggledEventArgs(FeatureToggle toggle, bool?oldValue, bool?newValue) : base(toggle) { OldValue = oldValue; NewValue = newValue; }