Esempio n. 1
0
        private IEnumerable <IFeatureToggle> BuildDependencies(Dictionary <string, KeyValuePair <JsonToggleConfig, IFeatureToggle> > toggles)
        {
            foreach (var t in toggles)
            {
                JsonToggleConfig config = t.Value.Key;
                IFeatureToggle   toggle = t.Value.Value;

                if (toggle is DependencyToggle dependencyToggle)
                {
                    BuildDependencies(dependencyToggle, toggles, config.Dependencies);
                }

                yield return(toggle);
            }
        }
Esempio n. 2
0
        private IFeatureToggle ConvertToFeatureToggle(JsonToggleConfig config)
        {
            IFeatureToggle toggle;

            if (config.IsEstablished)
            {
                toggle = new EstablishedFeatureToggle(config.Name);
            }
            else if ((config.FromDate != null) || (config.ToDate != null))
            {
                toggle = new DateRangeToggle(config.Name, config.Enabled, config.FromDate, config.ToDate);
            }
            else
            {
                toggle = new BooleanToggle(config.Name, config.Enabled);
            }

            return(config.Dependencies == null || !config.Dependencies.Any()
                ? toggle
                : new DependencyToggle(toggle));
        }