AcManager.Pages.Settings.SettingsQuickSwitches.ViewModel.ViewModel C# (CSharp) Method

ViewModel() public method

public ViewModel ( WidgetEntry>.IReadOnlyDictionary widgets ) : System.Collections.Generic
widgets WidgetEntry>.IReadOnlyDictionary
return System.Collections.Generic
            public ViewModel(IReadOnlyDictionary<string, WidgetEntry> widgets) {
                Widgets = widgets;

                var active = SettingsHolder.Drive.QuickSwitchesList;
                
                // clean up all invalid entries from saved list
                if (active.Any(x => !widgets.Keys.Contains(x))) {
                    active = active.Where(widgets.Keys.Contains).ToArray();
                    SettingsHolder.Drive.QuickSwitchesList = active;
                }

                Stored = new BetterObservableCollection<WidgetEntry>(Widgets.Values.Where(x => !active.Contains(x.Key)));
                Added = new BetterObservableCollection<WidgetEntry>(active.Select(x => Widgets.GetValueOrDefault(x)).NonNull());
                Added.CollectionChanged += Added_CollectionChanged;
            }
SettingsQuickSwitches.ViewModel