예제 #1
0
        private void UpdateToggles()
        {
            var selectedToggle = SelectedToggle;
            var toggleFilter   = ToggleFilter;

            var allToggles = _featureToggleService.GetToggles().OrderBy(x => x).ToList();

            if (!string.IsNullOrWhiteSpace(toggleFilter))
            {
                allToggles = allToggles.Where(x => x.Name.IndexOf(toggleFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
            }

            using (Toggles.SuspendChangeNotifications())
            {
                Toggles.Clear();

                foreach (var toggle in allToggles)
                {
                    if (!toggle.IsHidden)
                    {
                        Toggles.Add(toggle);
                    }
                }
            }

            // restore selection
            if (selectedToggle is not null && Toggles.Any(x => string.Equals(x.Name, selectedToggle)))
            {
                SelectedToggle = selectedToggle;
            }
        }