public static void AddSavedFeature(string name, bool enabled) { lock (features) { var feature = new FeatureSwitch(name, enabled); features [name] = feature; } }
public static void AddFeature(string name, bool?enabled) { lock (features) { features [name] = new FeatureSwitch(name, enabled.GetValueOrDefault()); } OnFeaturesChanged(); }
public override void ApplyChanges() { if (!changed) { return; } for (int row = 0; row < featuresListStore.RowCount; ++row) { bool enabled = featuresListStore.GetValue(row, featureEnabledDataField); FeatureSwitch feature = featuresListStore.GetValue(row, featureDataField); feature.Enabled = enabled; } FeatureSwitchConfigurations.OnFeaturesChanged(); }
public bool?IsFeatureEnabled(string featureName) { if (bypass) { return(null); } FeatureSwitch feature = FeatureSwitchConfigurations.GetFeature(featureName); if (feature == null) { bool?enabled = IsFeatureEnabledIgnoringConfiguration(featureName); FeatureSwitchConfigurations.AddFeature(featureName, enabled); } return(null); }
/// <summary> /// Gets registered features. The FeatureSwitchService.DescribeFeatures method is internal /// so we use reflection to get this information. /// </summary> public static IEnumerable <FeatureSwitch> DescribeFeatures() { try { MethodInfo method = typeof(FeatureSwitchService) .GetMethod(nameof(DescribeFeatures), BindingFlags.NonPublic | BindingFlags.Static); if (method == null) { LoggingService.LogError("Could not find FeatureSwitchService.DescribeFeatures method using reflection"); return(Enumerable.Empty <FeatureSwitch> ()); } var results = method.Invoke(null, new object[0]) as IEnumerable; if (results == null) { LoggingService.LogError("FeatureSwitchService.DescribeFeatures did not return an IEnumerable"); return(Enumerable.Empty <FeatureSwitch> ()); } var features = new List <FeatureSwitch> (); foreach (object featureSwitchObject in results) { FeatureSwitch feature = ConvertToFeatureSwitch(featureSwitchObject); if (feature != null) { features.Add(feature); } } return(features); } catch (Exception ex) { LoggingService.LogError("Failed to get features from FeatureSwitchService.DescribeFeatures", ex); } return(Enumerable.Empty <FeatureSwitch> ()); }