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

                if (toggle is DependencyToggle dependencyToggle)
                {
                    var dependencyNames = config.Dependencies.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    BuildDependencies(dependencyToggle, toggles, dependencyNames);
                }

                yield return(toggle);
            }
        }
Ejemplo n.º 2
0
        private IFeatureToggle ConvertToFeatureToggle(ToggleConfig 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(string.IsNullOrEmpty(config.Dependencies)
                ? toggle
                : new DependencyToggle(toggle));
        }