Esempio n. 1
0
        public void SetRule(string store, string key, string rule)
        {
            var featureStore     = FeatureStoreFactory.GetFeatureStore(store);
            var def              = featureStore.GetFeatureFlagDefinition(key);
            var p                = FeatureFlagEvaluatorUtils.Parse(key, def.Definition);
            var dynamicEvaluator = p as DynamicFeatureFlagStateEvaluator ?? new DynamicFeatureFlagStateEvaluator(key, new FeatureRulesDefinition());

            dynamicEvaluator.Rules.ActiveExpression = rule;
            featureStore.SetFeatureFlagDefinition(new FeatureFlagDefinition {
                Name = key, Definition = FeatureFlagEvaluatorUtils.SerializeRules(dynamicEvaluator.Rules)
            });
        }
Esempio n. 2
0
        public void Dectivate(string store, string key)
        {
            var featureStore     = FeatureStoreFactory.GetFeatureStore(store);
            var def              = featureStore.GetFeatureFlagDefinition(key);
            var p                = FeatureFlagEvaluatorUtils.Parse(key, def.Definition);
            var dynamicEvaluator = p as DynamicFeatureFlagStateEvaluator;

            if (dynamicEvaluator != null)
            {
                dynamicEvaluator.Rules.OverrideValue = false;
                featureStore.SetFeatureFlagDefinition(new FeatureFlagDefinition {
                    Name = key, Definition = FeatureFlagEvaluatorUtils.SerializeRules(dynamicEvaluator.Rules)
                });
            }
            else
            {
                featureStore.SetFeatureFlagDefinition(new FeatureFlagDefinition {
                    Name = key, Definition = "false"
                });
            }
        }