using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; namespace Dominion.NET_WPF.ViewModel { internal class AIListViewModel { public ObservableCollection AIs { get; set; } public void ShowAIs(IEnumerable ais) { AIs = new ObservableCollection(); foreach (var type in ais) AIs.Add(new AIViewModel { AI = type, IsChecked = false }); } public AIListViewModel() { AIs = new ObservableCollection(); } public AIListViewModel(IEnumerable ais, ICollection allowedAIs) { AIs = new ObservableCollection(); foreach (var type in ais) AIs.Add(new AIViewModel { AI = type, IsChecked = allowedAIs.Contains(type.FullName) }); } protected static IEnumerable ExtractData(object data) { var models = data as IEnumerable; return models ?? Enumerable.Repeat((AIViewModel) data, 1); } protected static IList GetList(IEnumerable enumerable) { if (enumerable is ICollectionView collectionView) return collectionView.SourceCollection as IList; return enumerable as IList; } } }